trivial: Improve logging of run commands

Change-Id: I5ee1f506a162692fe2882651f7ab68afb441aacf
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2020-07-09 10:09:29 +01:00 committed by Stephen Finucane
parent 206b795517
commit d8f740c6a8
1 changed files with 5 additions and 2 deletions

View File

@ -202,12 +202,15 @@ def _run_cmd(args, cwd):
:param cwd: The directory to run the comamnd in.
:return: ((stdout, stderr), returncode)
"""
print('Running %s' % ' '.join(args))
p = subprocess.Popen(
args, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, cwd=cwd)
streams = tuple(s.decode('latin1').strip() for s in p.communicate())
for stream_content in streams:
print(stream_content)
print('STDOUT:')
print(streams[0])
print('STDERR:')
print(streams[1])
return (streams) + (p.returncode,)