summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-11-11 15:24:45 +0000
committerCarl Hetherington <cth@carlh.net>2014-11-11 15:24:45 +0000
commitbe4638a804ed5a94058f10de81da6aa41a6e13be (patch)
treef127a7a5be5e2a69571f7c8be17c6c3a5f9665cc
parentc30a9725c6c04bd1c0a1922a61dbfdab21821cf8 (diff)
Return errors when os.system fails.scp
-rwxr-xr-xcdist10
1 files 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)