Skip to contentSkip to conversation

hob: report event handler failures

PATCH Applied Paul Eggleton 3 participants 3 messages Sep 19, 2012 – Sep 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hob: report event handler failures

If an event handler failed we were not recieving an error message - parsing just "froze" at 99%. This is because we were expecting a CommandFailure event and this never happened in the case of RequestPackageInfo which is where the failure was occurring.

This also required tweaking the error formatting slightly, taking the return value of the format function rather than the message property since the latter only seems to contain the first line without the traceback in the case of event handler failure. Other error cases were tested and their message formatting is unaffected by this change.

Final part of the fix for [YOCTO #2651].

---
 bitbake/lib/bb/ui/crumbs/hobeventhandler.py |   20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
bitbake/lib/bb/ui/crumbs/hobeventhandler.py +13 -7
index 35cbded..8fc1732 100644
@@ -156,6 +156,13 @@ class HobHandler(gobject.GObject):
                 targets.append(self.toolchain)
             self.runCommand(["buildTargets", targets, self.default_task])
 
+    def display_error(self):
+        self.clear_busy()
+        self.emit("command-failed", self.error_msg)
+        self.error_msg = ""
+        if self.building:
+            self.building = False
+
     def handle_event(self, event):
         if not event:
             return
@@ -178,8 +185,8 @@ class HobHandler(gobject.GObject):
         elif isinstance(event, logging.LogRecord):
             if event.levelno >= logging.ERROR:
                 formatter = bb.msg.BBLogFormatter()
-                formatter.format(event)
-                self.error_msg += event.message + '\n'
+                msg = formatter.format(event)
+                self.error_msg += msg + '\n'
 
         elif isinstance(event, bb.event.TargetsTreeGenerated):
             self.current_phase = "data generation"
@@ -211,11 +218,7 @@ class HobHandler(gobject.GObject):
             self.run_next_command()
         elif isinstance(event, bb.command.CommandFailed):
             self.commands_async = []
-            self.clear_busy()
-            self.emit("command-failed", self.error_msg)
-            self.error_msg = ""
-            if self.building:
-                self.building = False
+            self.display_error()
         elif isinstance(event, (bb.event.ParseStarted,
                  bb.event.CacheLoadStarted,
                  bb.event.TreeDataPreparationStarted,
@@ -245,6 +248,9 @@ class HobHandler(gobject.GObject):
             message["title"] = "Parsing recipes: "
             self.emit("parsing-completed", message)
 
+        if self.error_msg and not self.commands_async:
+            self.display_error()
+
         return
 
     def init_cooker(self):
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 11 lines · Paul Eggleton

If an event handler failed we were not recieving an error message - parsing just "froze" at 99%. This is because we were expecting a CommandFailure event and this never happened in the case of RequestPackageInfo which is where the failure was occurring.

This also required tweaking the error formatting slightly, taking the return value of the format function rather than the message property since the latter only seems to contain the first line without the traceback in the case of event handler failure. Other error cases were tested and their message formatting is unaffected by this change.

This looks good Paul.

Thanks for fixing this up so we can get the reporting. :-)

Cheers,
Jason.

#2 lore raw
In reply to Paul Eggleton
Quoted 11 lines · Paul Eggleton

If an event handler failed we were not recieving an error message - parsing just "froze" at 99%. This is because we were expecting a CommandFailure event and this never happened in the case of RequestPackageInfo which is where the failure was occurring.

This also required tweaking the error formatting slightly, taking the return value of the format function rather than the message property since the latter only seems to contain the first line without the traceback in the case of event handler failure. Other error cases were tested and their message formatting is unaffected by this change.

Quoted 3 lines

Final part of the fix for [YOCTO #2651].

Merged to master, thanks.

Richard