Print the driver stdout/stderr if we fail to decode it in jenkins. (#567)

* Print the driver stdout/stderr if we fail to decode it in jenkins.

* Fix whitespace.

* Add explanation.
This commit is contained in:
Robert Nishihara
2017-05-20 23:11:19 -07:00
committed by Philipp Moritz
parent 849d2aaf47
commit 07b21e057c
+19 -4
View File
@@ -20,10 +20,25 @@ def wait_for_output(proc):
A tuple of the stdout and stderr of the process as strings.
"""
stdout_data, stderr_data = proc.communicate()
stdout_data = (stdout_data.decode("ascii") if stdout_data is not None
else None)
stderr_data = (stderr_data.decode("ascii") if stderr_data is not None
else None)
if stdout_data is not None:
try:
# NOTE(rkn): This try/except block is here because I once saw an
# exception raised here and want to print more information if that
# happens again.
stdout_data = stdout_data.decode("ascii")
except UnicodeDecodeError:
raise Exception("Failed to decode stdout_data:", stdout_data)
if stderr_data is not None:
try:
# NOTE(rkn): This try/except block is here because I once saw an
# exception raised here and want to print more information if that
# happens again.
stderr_data = stderr_data.decode("ascii")
except UnicodeDecodeError:
raise Exception("Failed to decode stderr_data:", stderr_data)
return stdout_data, stderr_data