add stderr to exception raised by command_output

This commit is contained in:
Fabrice Laporte 2014-09-17 21:58:14 +02:00
parent 26ec2b8d2b
commit a06c278a20

View file

@ -633,13 +633,14 @@ def command_output(cmd, shell=False):
Python 2.6 and which can have problems if lots of output is sent to
stderr.
"""
with open(os.devnull, 'wb') as devnull:
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=devnull,
close_fds=platform.system() != 'Windows',
shell=shell)
stdout, _ = proc.communicate()
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=platform.system() != 'Windows',
shell=shell)
stdout, stderr = proc.communicate()
if proc.returncode:
raise subprocess.CalledProcessError(proc.returncode, cmd)
raise subprocess.CalledProcessError(proc.returncode, cmd, stderr)
return stdout