All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Woolley <rob.woolley@windriver.com>
To: <bitbake-devel@lists.openembedded.org>
Subject: [PATCH 1/3] knotty: Catch exceptions on broken pipes
Date: Fri, 27 Feb 2015 09:32:22 -0500	[thread overview]
Message-ID: <1425047544-4820-2-git-send-email-rob.woolley@windriver.com> (raw)
In-Reply-To: <1425047544-4820-1-git-send-email-rob.woolley@windriver.com>

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>
---
 lib/bb/ui/knotty.py | 43 ++++++++++++++++++++++++-------------------
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index ea20ddc..09a4e0c 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -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
-- 
1.8.3.1



  reply	other threads:[~2015-02-27 14:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-27 14:32 [PATCH 0/3] knotty: Add automatic pager support Rob Woolley
2015-02-27 14:32 ` Rob Woolley [this message]
2015-02-27 14:32 ` [PATCH 2/3] knotty: Do not log show_versions output Rob Woolley
2015-02-27 14:32 ` [PATCH 3/3] knotty: Add automatic paging for bitbake -s and -e Rob Woolley
2015-03-12 15:25 ` [PATCH 0/3] knotty: Add automatic pager support Rob Woolley
2015-03-12 16:30   ` Richard Purdie
2015-03-13 19:41     ` Woolley, Rob
2015-03-13 21:12       ` Bernhard Reutner-Fischer
2015-03-13 21:37         ` Bernhard Reutner-Fischer
2015-03-17 15:05           ` Woolley, Rob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425047544-4820-2-git-send-email-rob.woolley@windriver.com \
    --to=rob.woolley@windriver.com \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.