Write subprocess stdout/stderr logs to raw stdout buffer when using Python3

This commit is contained in:
marmeladema 2019-12-09 21:17:34 +00:00
parent 63d5d8a4b6
commit 17233f2dd2

View file

@ -104,13 +104,22 @@ def _process_exec(args):
if process.returncode:
print('"%s" failed with error code %d:' % ('" "'.join(args), process.returncode))
if sys.version_info >= (3, 0):
stdout = sys.stdout.buffer
else:
stdout = sys.stdout
print('Output:')
out.seek(0)
shutil.copyfileobj(out, sys.stdout)
stdout.flush()
shutil.copyfileobj(out, stdout)
stdout.flush()
print('Error:')
err.seek(0)
shutil.copyfileobj(err, sys.stdout)
stdout.flush()
shutil.copyfileobj(err, stdout)
stdout.flush()
sys.exit(1)