[Toaster] [review-request][PATCH 1/4] command: fire CommandExecution event before a command runs

Elliot Smith elliot.smith at intel.com
Tue Feb 2 06:46:46 PST 2016


Cooker commands and the arguments passed to them are currently
inaccessible to UI components which may need that data. For
example, knowing the targets passed on the command line could
enable a UI to show the targets in cases where the build failed
due to an invalid target.

Add events to Command which are fired just before a sync or async
command is started, containing data about the command which
is going to run and its arguments.

Add the new event to knotty's event mask to avoid seeing
"Unknown event" errors when bitbake is run on the command line.

Signed-off-by: Elliot Smith <elliot.smith at intel.com>
---
 bitbake/lib/bb/command.py   |  7 +++++++
 bitbake/lib/bb/ui/knotty.py | 10 ++++++----
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 74106d1..3f3a7a7 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -31,6 +31,11 @@ Commands are queued in a CommandQueue
 import bb.event
 import bb.cooker
 
+class CommandExecution(bb.event.Event):
+    def __init__(self, command, commandline):
+        self.command = command
+        self.commandline = commandline
+
 class CommandCompleted(bb.event.Event):
     pass
 
@@ -70,6 +75,7 @@ class Command:
             try:
                 if getattr(command_method, 'needconfig', False):
                     self.cooker.updateCacheSync()
+                bb.event.fire(CommandExecution(command, commandline), self.cooker.expanded_data)
                 result = command_method(self, commandline)
             except CommandError as exc:
                 return None, exc.args[0]
@@ -101,6 +107,7 @@ class Command:
                     self.cooker.updateCache()
                     return True
                 else:
+                    bb.event.fire(CommandExecution(command, options), self.cooker.expanded_data)
                     commandmethod(self.cmds_async, self, options)
                     return False
             else:
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index a8b968c..335e6f9 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -245,9 +245,10 @@ _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.Lo
               "bb.build.TaskFailed", "bb.build.TaskBase", "bb.event.ParseStarted",
               "bb.event.ParseProgress", "bb.event.ParseCompleted", "bb.event.CacheLoadStarted",
               "bb.event.CacheLoadProgress", "bb.event.CacheLoadCompleted", "bb.command.CommandFailed",
-              "bb.command.CommandExit", "bb.command.CommandCompleted",  "bb.cooker.CookerExit",
-              "bb.event.MultipleProviders", "bb.event.NoProvider", "bb.runqueue.sceneQueueTaskStarted",
-              "bb.runqueue.runQueueTaskStarted", "bb.runqueue.runQueueTaskFailed", "bb.runqueue.sceneQueueTaskFailed",
+              "bb.command.CommandExit", "bb.command.CommandCompleted", "bb.cooker.CommandExecution",
+              "bb.cooker.CookerExit", "bb.event.MultipleProviders", "bb.event.NoProvider",
+              "bb.runqueue.sceneQueueTaskStarted", "bb.runqueue.runQueueTaskStarted",
+              "bb.runqueue.runQueueTaskFailed", "bb.runqueue.sceneQueueTaskFailed",
               "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent"]
 
 def main(server, eventHandler, params, tf = TerminalFilter):
@@ -514,7 +515,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
                                   bb.event.OperationStarted,
                                   bb.event.OperationCompleted,
                                   bb.event.OperationProgress,
-                                  bb.event.DiskFull)):
+                                  bb.event.DiskFull,
+                                  bb.command.CommandExecution)):
                 continue
 
             logger.error("Unknown event: %s", event)
-- 
Elliot Smith
Software Engineer
Intel OTC

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.



More information about the toaster mailing list