From: Rob Browning Date: Sun, 23 Mar 2014 22:52:59 +0000 (-0500) Subject: helpers.py: check subprocess exit status in readpipe(). X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=829c5fbbf08198e9fc498d9ce4932882ba37dc95;p=packages%2Fb%2Fbup.git helpers.py: check subprocess exit status in readpipe(). Checking the exit status seems like a good idea. Note that we can't just use check_output() because it wasn't added until Python 2.7. Thanks to Alexander Barton for reporting the version incompatibility with respect to an earlier version of this patch. Signed-off-by: Rob Browning --- diff --git a/lib/bup/helpers.py b/lib/bup/helpers.py index a169196..a56f656 100644 --- a/lib/bup/helpers.py +++ b/lib/bup/helpers.py @@ -180,9 +180,11 @@ def unlink(f): def readpipe(argv): """Run a subprocess and return its output.""" p = subprocess.Popen(argv, stdout=subprocess.PIPE) - r = p.stdout.read() - p.wait() - return r + out, err = p.communicate() + if p.returncode != 0: + raise Exception('subprocess %r failed with status %d' + % (' '.join(argv), p.retcode)) + return out def realpath(p):