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 <alex@barton.de> for reporting the version
incompatibility with respect to an earlier version of this patch.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
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):