]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
knotty: Catch exceptions on broken pipes
authorRob Woolley <rob.woolley@windriver.com>
Fri, 27 Feb 2015 14:32:22 +0000 (09:32 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Mar 2015 17:39:48 +0000 (17:39 +0000)
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.

Signed-off-by: Rob Woolley <rob.woolley@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
lib/bb/ui/knotty.py

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