]> code.ossystems Code Review - openembedded-core.git/commitdiff
Show the user progress when loading the cache
authorBob Foerster <rfoerster@layerzero.com>
Mon, 22 Nov 2010 15:13:56 +0000 (10:13 -0500)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 4 Jan 2011 14:46:51 +0000 (14:46 +0000)
(Bitbake rev: bdd7813d8eecf7b6b636322e748ca6bf69118513)

Signed-off-by: Bob Foerster <robert@erafx.com>
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/cache.py
bitbake/lib/bb/cooker.py
bitbake/lib/bb/event.py
bitbake/lib/bb/ui/knotty.py

index b3c632b81cefd2ea77f7b1cd0fcefafb69ef854e..fb02deb8ef8fccdc7b5c625dea3b1e986d404a8f 100644 (file)
@@ -204,14 +204,31 @@ class Cache(object):
                 logger.info('Bitbake version mismatch, rebuilding...')
                 return
 
+            cachesize = os.fstat(cachefile.fileno()).st_size
+            bb.event.fire(bb.event.CacheLoadStarted(cachesize), self.data)
+
+            previous_percent = 0
             while cachefile:
                 try:
                     key = pickled.load()
                     value = pickled.load()
                 except Exception:
                     break
+
                 self.depends_cache[key] = value
 
+                # only fire events on even percentage boundaries
+                current_progress = cachefile.tell()
+                current_percent = 100 * current_progress / cachesize
+                if current_percent > previous_percent:
+                    previous_percent = current_percent
+                    bb.event.fire(bb.event.CacheLoadProgress(current_progress),
+                                  self.data)
+
+            bb.event.fire(bb.event.CacheLoadCompleted(cachesize,
+                                                      len(self.depends_cache)),
+                          self.data)
+
     @staticmethod
     def virtualfn2realfn(virtualfn):
         """
index 7a9b1d58d67fc88ca12b329760ec653bfff469d8..548273380f69d65dbd671416b4c48e9db9ef7d69 100644 (file)
@@ -1055,6 +1055,7 @@ class CookerParser(object):
             self.shutdown(clean=False)
             bb.fatal('Error parsing %s: %s' % (exc.recipe, exc))
 
+
         self.current += 1
         self.virtuals += len(result)
         if parsed:
index c2bacc50c20b0614efa6a93e377328a391c80672..ad53ba015cf1edaa57239081932ea05a326714d5 100644 (file)
@@ -324,6 +324,25 @@ class ParseProgress(Event):
     def __init__(self, current):
         self.current = current
 
+class CacheLoadStarted(Event):
+    """Loading of the dependency cache has begun"""
+    def __init__(self, total):
+        Event.__init__(self)
+        self.total = total
+
+class CacheLoadProgress(Event):
+    """Cache loading progress"""
+    def __init__(self, current):
+        Event.__init__(self)
+        self.current = current
+
+class CacheLoadCompleted(Event):
+    """Cache loading is complete"""
+    def __init__(self, total, num_entries):
+        Event.__init__(self)
+        self.total = total
+        self.num_entries = num_entries
+
 class DepTreeGenerated(Event):
     """
     Event when a dependency tree has been generated
index 69a84f78300b886ffd9554779eca3b70b646f926..b9ad34f16a02314c8f2828be2c3951d04ff3b4ad 100644 (file)
@@ -31,12 +31,14 @@ from bb import ui
 from bb.ui import uihelper
 
 logger = logging.getLogger("BitBake")
-widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
-           progressbar.ETA()]
+interactive = sys.stdout.isatty()
 
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval):
         self.msg = msg
+        widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
+           progressbar.ETA()]
+
         progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets)
 
 class NonInteractiveProgress(object):
@@ -58,6 +60,12 @@ class NonInteractiveProgress(object):
         self.fobj.write("done.\n")
         self.fobj.flush()
 
+def new_progress(msg, maxval):
+    if interactive:
+        return BBProgress(msg, maxval)
+    else:
+        return NonInteractiveProgress(msg, maxval)
+
 def main(server, eventHandler):
 
     # Get values of variables which control our output
@@ -93,8 +101,9 @@ def main(server, eventHandler):
         print("XMLRPC Fault getting commandline:\n %s" % x)
         return 1
 
+
     parseprogress = None
-    interactive = os.isatty(sys.stdout.fileno())
+    cacheprogress = None
     shutdown = 0
     return_value = 0
     while True:
@@ -149,11 +158,7 @@ def main(server, eventHandler):
                 logger.info(event._message)
                 continue
             if isinstance(event, bb.event.ParseStarted):
-                if interactive:
-                    progress = BBProgress
-                else:
-                    progress = NonInteractiveProgress
-                parseprogress = progress("Parsing recipes", event.total).start()
+                parseprogress = new_progress("Parsing recipes", event.total).start()
                 continue
             if isinstance(event, bb.event.ParseProgress):
                 parseprogress.update(event.current)
@@ -164,6 +169,17 @@ def main(server, eventHandler):
                     % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
                 continue
 
+            if isinstance(event, bb.event.CacheLoadStarted):
+                cacheprogress = new_progress("Loading cache", event.total).start()
+                continue
+            if isinstance(event, bb.event.CacheLoadProgress):
+                cacheprogress.update(event.current)
+                continue
+            if isinstance(event, bb.event.CacheLoadCompleted):
+                cacheprogress.finish()
+                print("Loaded %d entries from dependency cache." % event.num_entries)
+                continue
+
             if isinstance(event, bb.command.CommandCompleted):
                 break
             if isinstance(event, bb.command.CommandFailed):