From be4638a804ed5a94058f10de81da6aa41a6e13be Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 11 Nov 2014 15:24:45 +0000 Subject: Return errors when os.system fails. --- cdist | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cdist b/cdist index 95e0e96..812f06d 100755 --- a/cdist +++ b/cdist @@ -120,20 +120,24 @@ def scp_escape(n): else: return '\"%s\"' % s[0] +def command(c): + if os.system(c) != 0: + raise Error('%s failed' % c) + def copytree(a, b): log('copy %s -> %s' % (scp_escape(b), scp_escape(b))) - os.system('scp -r %s %s' % (scp_escape(a), scp_escape(b))) + command('scp -r %s %s' % (scp_escape(a), scp_escape(b))) def copyfile(a, b): log('copy %s -> %s' % (scp_escape(a), scp_escape(b))) - os.system('scp %s %s' % (scp_escape(a), scp_escape(b))) + command('scp %s %s' % (scp_escape(a), scp_escape(b))) def makedirs(d): if d.find(':') == -1: os.makedirs(d) else: s = d.split(':') - os.system('ssh %s -- mkdir -p %s' % (s[0], s[1])) + command('ssh %s -- mkdir -p %s' % (s[0], s[1])) def rmdir(a): log('remove %s' % a) -- cgit v1.2.3