diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-11-11 15:24:45 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-11-11 15:24:45 +0000 |
| commit | be4638a804ed5a94058f10de81da6aa41a6e13be (patch) | |
| tree | f127a7a5be5e2a69571f7c8be17c6c3a5f9665cc | |
| parent | c30a9725c6c04bd1c0a1922a61dbfdab21821cf8 (diff) | |
Return errors when os.system fails.scp
| -rwxr-xr-x | cdist | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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) |
