Arbitrarily large output can't be used in an exception.

It seems like we are seeing whacky errors with sys.stderr
dying when trying to print out a process and its exception.
I think controlling how the output is printed in RunCommand
is better than passing it with the exception.

Change-Id: I3711575e5d9e710c3aea6ff19d43d149fd83f44c

BUG=chromium-os:14398
TEST=Ran it with au_test_harness

Review URL: http://codereview.chromium.org/6902129
This commit is contained in:
Chris Sosa 2011-04-28 15:29:12 -07:00
parent 118692ab3f
commit 237b686be8

View File

@ -110,8 +110,12 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
# If the command (and all retries) failed, handle error result # If the command (and all retries) failed, handle error result
if proc.returncode != 0 and not error_ok: if proc.returncode != 0 and not error_ok:
if output:
print >> sys.stderr, output
sys.stderr.flush()
error_info = ('Command "%r" failed.\n' % (cmd) + error_info = ('Command "%r" failed.\n' % (cmd) +
(error_message or error or output or '')) (error_message or error or ''))
if log_to_file: error_info += '\nOutput logged to %s' % log_to_file if log_to_file: error_info += '\nOutput logged to %s' % log_to_file
raise RunCommandException(error_info) raise RunCommandException(error_info)