bitbake: knotty: Catch exceptions on broken pipes

Any exceptions that occur in calls to logging methods are automatically
suppressed, including exceptions due to broken pipes.

However, the knotty summary messages are printed directly to stdout, which
means that any broken pipes will cause an exception traceback in python.

By wrapping the summary section in a try / catch block we can check for
IOError exceptions caused by broken pipes and let them pass.

(Bitbake rev: 146e7e157f97b676858ecff583dd53800d997253)

Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Rob Woolley
2015-02-27 09:32:22 -05:00
committed by Richard Purdie
parent 7f30749fe0
commit 0b5ab4d987

View File

@@ -536,24 +536,29 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if not params.observe_only: if not params.observe_only:
_, error = server.runCommand(["stateForceShutdown"]) _, error = server.runCommand(["stateForceShutdown"])
main.shutdown = 2 main.shutdown = 2
summary = "" try:
if taskfailures: summary = ""
summary += pluralise("\nSummary: %s task failed:", if taskfailures:
"\nSummary: %s tasks failed:", len(taskfailures)) summary += pluralise("\nSummary: %s task failed:",
for failure in taskfailures: "\nSummary: %s tasks failed:", len(taskfailures))
summary += "\n %s" % failure for failure in taskfailures:
if warnings: summary += "\n %s" % failure
summary += pluralise("\nSummary: There was %s WARNING message shown.", if warnings:
"\nSummary: There were %s WARNING messages shown.", warnings) summary += pluralise("\nSummary: There was %s WARNING message shown.",
if return_value and errors: "\nSummary: There were %s WARNING messages shown.", warnings)
summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", if return_value and errors:
"\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.",
if summary: "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors)
print(summary) if summary:
print(summary)
if interrupted: if interrupted:
print("Execution was interrupted, returning a non-zero exit code.") print("Execution was interrupted, returning a non-zero exit code.")
if return_value == 0: if return_value == 0:
return_value = 1 return_value = 1
except IOError as e:
import errno
if e.errno == errno.EPIPE:
pass
return return_value return return_value