summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-11-20 12:05:42 +0100
committerCarl Hetherington <cth@carlh.net>2020-11-20 12:05:42 +0100
commit02b8f1135e0536f87fbc1a68a00fb8201dc5fced (patch)
treecb2e5445ec2eee4d2fbfb76d2a80e989016b145e
parente59e21f95a8843535d14641a300f78c68942d381 (diff)
Replace os.system with subprocess.run so that it's easier to report errors correctly on Windows.
-rwxr-xr-xcdist9
1 files changed, 6 insertions, 3 deletions
diff --git a/cdist b/cdist
index 6011338..c9f15a0 100755
--- a/cdist
+++ b/cdist
@@ -256,9 +256,12 @@ def rmtree(a):
def command(c):
log_normal(c)
- r = os.system(c)
- if (r >> 8):
- raise Error('command %s failed' % c)
+ try:
+ r = subprocess.run(shlex.split(c))
+ if r.returncode != 0:
+ raise Error(f'command {c} failed ({r.returncode})')
+ except Exception as e:
+ raise Error(f'command {c} failed ({e})')
def command_and_read(c):
log_normal(c)