]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
Rename command events, adjust compareRevisions
authorChris Larson <chris_larson@mentor.com>
Fri, 10 Dec 2010 23:53:19 +0000 (16:53 -0700)
committerChris Larson <chris_larson@mentor.com>
Sat, 11 Dec 2010 00:12:27 +0000 (17:12 -0700)
- Moved the logic for comparing revisions from cooker into command
- Removed 'Cooker' from the event names
- Renamed the 'ExitCode' event into CommandExit, and changed CommandFailed to
  be a subclass of CommandExit

Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/command.py
lib/bb/cooker.py
lib/bb/fetch/__init__.py
lib/bb/ui/depexp.py
lib/bb/ui/knotty.py
lib/bb/ui/ncurses.py

index 30c7240cf2bb41ffa350b2691a37b5c4d9637395..b88089298cab6aaaeee2c204901143bd1610b772 100644 (file)
@@ -35,12 +35,25 @@ import bb.data
 async_cmds = {}
 sync_cmds = {}
 
+
+class CommandCompleted(bb.event.Event):
+    pass
+
+class CommandExit(bb.event.Event):
+    def  __init__(self, exitcode):
+        bb.event.Event.__init__(self)
+        self.exitcode = int(exitcode)
+
+class CommandFailed(CommandExit):
+    def __init__(self, message):
+        self.error = message
+        CommandExit.__init__(self, 1)
+
 class Command:
     """
     A queue of asynchronous commands for bitbake
     """
     def __init__(self, cooker):
-
         self.cooker = cooker
         self.cmds_sync = CommandsSync()
         self.cmds_async = CommandsAsync()
@@ -105,11 +118,13 @@ class Command:
             self.finishAsyncCommand(traceback.format_exc())
             return False
 
-    def finishAsyncCommand(self, error = None):
-        if error:
-            bb.event.fire(CookerCommandFailed(error), self.cooker.configuration.event_data)
+    def finishAsyncCommand(self, msg=None, code=None):
+        if msg:
+            bb.event.fire(CommandFailed(msg), self.cooker.configuration.event_data)
+        elif code:
+            bb.event.fire(CommandExit(code), self.cooker.configuration.event_data)
         else:
-            bb.event.fire(CookerCommandCompleted(), self.cooker.configuration.event_data)
+            bb.event.fire(CommandCompleted(), self.cooker.configuration.event_data)
         self.currentAsyncCommand = None
 
 
@@ -249,33 +264,8 @@ class CommandsAsync:
         """
         Parse the .bb files
         """
-        command.cooker.compareRevisions()
-        command.finishAsyncCommand()
+        if bb.fetch.fetcher_compare_revisions(command.cooker.configuration.data):
+            command.finishAsyncCommand(code=1)
+        else:
+            command.finishAsyncCommand()
     compareRevisions.needcache = True
-
-#
-# Events
-#
-class CookerCommandCompleted(bb.event.Event):
-    """
-    Cooker command completed
-    """
-    def  __init__(self):
-        bb.event.Event.__init__(self)
-
-
-class CookerCommandFailed(bb.event.Event):
-    """
-    Cooker command completed
-    """
-    def  __init__(self, error):
-        bb.event.Event.__init__(self)
-        self.error = error
-
-class CookerCommandSetExitCode(bb.event.Event):
-    """
-    Set the exit code for a cooker command
-    """
-    def  __init__(self, exitcode):
-        bb.event.Event.__init__(self)
-        self.exitcode = int(exitcode)
index f4bdb8154bacf6c44859226a162a7abd77d607ee..185f5e244f5d7a19fa6fcec0a6d7970585112c27 100644 (file)
@@ -188,10 +188,6 @@ class BBCooker:
 
             logger.plain("%-35s %25s %25s", p, lateststr, prefstr)
 
-    def compareRevisions(self):
-        ret = bb.fetch.fetcher_compare_revisons(self.configuration.data)
-        bb.event.fire(bb.command.CookerCommandSetExitCode(ret), self.configuration.event_data)
-
     def showEnvironment(self, buildfile = None, pkgs_to_build = []):
         """
         Show the outer or per-package environment
index 6fa0afaac40f643abac5d87a2d9af41dc68186c2..bb4e63b687742d5a0d3d3f8053963f74ca7c52c0 100644 (file)
@@ -173,7 +173,7 @@ def fetcher_init(d):
     pd.addDomain("BB_URI_HEADREVS")
     pd.addDomain("BB_URI_LOCALCOUNT")
 
-def fetcher_compare_revisons(d):
+def fetcher_compare_revisions(d):
     """
     Compare the revisions in the persistant cache with current values and
     return true/false on whether they've changed.
index f0297a3bcfa0844cea02d7e56c2722c673bb03a7..967f3079011e30263d4793c16c2ec652d57aef98 100644 (file)
@@ -21,6 +21,8 @@ import gobject
 import gtk
 import threading
 import xmlrpclib
+import bb
+import bb.event
 from bb.ui.crumbs.progress import ProgressBar
 
 # Package Model
@@ -236,11 +238,13 @@ def main(server, eventHandler):
                 parse(event._depgraph, dep.pkg_model, dep.depends_model)
                 gtk.gdk.threads_leave()
 
-            if isinstance(event, bb.command.CookerCommandCompleted):
+            if isinstance(event, bb.command.CommandCompleted):
                 continue
-            if isinstance(event, bb.command.CookerCommandFailed):
+            if isinstance(event, bb.command.CommandFailed):
                 print("Command execution failed: %s" % event.error)
-                break
+                return event.exitcode
+            if isinstance(event, bb.command.CommandExit):
+                return event.exitcode
             if isinstance(event, bb.cooker.CookerExit):
                 break
 
index b8cb2c05e59c00d5fdcd8252b5ee8fdb25e542f6..8a7b2b760de175f0e18d542a0c24ee741323a97c 100644 (file)
@@ -160,15 +160,15 @@ def main(server, eventHandler):
                     % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
                 continue
 
-            if isinstance(event, bb.command.CookerCommandCompleted):
+            if isinstance(event, bb.command.CommandCompleted):
                 break
-            if isinstance(event, bb.command.CookerCommandSetExitCode):
+            if isinstance(event, bb.command.CommandFailed):
                 return_value = event.exitcode
-                continue
-            if isinstance(event, bb.command.CookerCommandFailed):
-                return_value = 1
                 logger.error("Command execution failed: %s" % event.error)
                 break
+            if isinstance(event, bb.command.CommandExit):
+                return_value = event.exitcode
+                continue
             if isinstance(event, bb.cooker.CookerExit):
                 break
             if isinstance(event, bb.event.MultipleProviders):
index 3bc8373964641b3f5d05352546c52fe449203fb3..1db4ec173b78824e945a3fa4ebf0378954333b5c 100644 (file)
@@ -288,12 +288,14 @@ class NCursesUI:
 #                        else:
 #                            bb.msg.error(bb.msg.domain.Build, "see log in %s" % logfile)
 
-                if isinstance(event, bb.command.CookerCommandCompleted):
+                if isinstance(event, bb.command.CommandCompleted):
                     exitflag = True
-                if isinstance(event, bb.command.CookerCommandFailed):
+                if isinstance(event, bb.command.CommandFailed):
                     mw.appendText("Command execution failed: %s" % event.error)
                     time.sleep(2)
                     exitflag = True
+                if isinstance(event, bb.command.CommandExit):
+                    exitflag = True
                 if isinstance(event, bb.cooker.CookerExit):
                     exitflag = True