diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-18 21:15:07 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:42 +0000 |
commit | 9ffbd9fe27e25a458b09631c503f4ef96632e334 (patch) | |
tree | f0d8f9291aaa1afe9c2f31ffa629dd27372b2678 /bitbake/lib/bb/ui/knotty.py | |
parent | 32ea7668712a50d8f8b67d5e4558039e5092a485 (diff) | |
download | poky-9ffbd9fe27e25a458b09631c503f4ef96632e334.tar.gz |
Experimental usage of the 'progressbar' module
(Bitbake rev: 64feb03bc2accecb49033df65e0a939ef5ab5986)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/ui/knotty.py')
-rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 177a12609c..a34991bb68 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py | |||
@@ -25,11 +25,13 @@ import sys | |||
25 | import itertools | 25 | import itertools |
26 | import xmlrpclib | 26 | import xmlrpclib |
27 | import logging | 27 | import logging |
28 | import progressbar | ||
28 | from bb import ui | 29 | from bb import ui |
29 | from bb.ui import uihelper | 30 | from bb.ui import uihelper |
30 | 31 | ||
31 | logger = logging.getLogger("BitBake") | 32 | logger = logging.getLogger("BitBake") |
32 | parsespin = itertools.cycle( r'|/-\\' ) | 33 | widgets = ['Parsing recipes: ', progressbar.Percentage(), ' ', |
34 | progressbar.Bar(), ' ', progressbar.ETA()] | ||
33 | 35 | ||
34 | class BBLogFormatter(logging.Formatter): | 36 | class BBLogFormatter(logging.Formatter): |
35 | """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is""" | 37 | """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is""" |
@@ -75,6 +77,7 @@ def init(server, eventHandler): | |||
75 | print("XMLRPC Fault getting commandline:\n %s" % x) | 77 | print("XMLRPC Fault getting commandline:\n %s" % x) |
76 | return 1 | 78 | return 1 |
77 | 79 | ||
80 | pbar = None | ||
78 | shutdown = 0 | 81 | shutdown = 0 |
79 | return_value = 0 | 82 | return_value = 0 |
80 | while True: | 83 | while True: |
@@ -130,19 +133,20 @@ def init(server, eventHandler): | |||
130 | logger.info(event._message) | 133 | logger.info(event._message) |
131 | continue | 134 | continue |
132 | if isinstance(event, bb.event.ParseProgress): | 135 | if isinstance(event, bb.event.ParseProgress): |
133 | x = event.sofar | 136 | current, total = event.sofar, event.total |
134 | y = event.total | ||
135 | if os.isatty(sys.stdout.fileno()): | 137 | if os.isatty(sys.stdout.fileno()): |
136 | sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( next(parsespin), x, y, x*100//y ) ) | 138 | if not pbar: |
137 | sys.stdout.flush() | 139 | pbar = progressbar.ProgressBar(widgets=widgets, |
140 | maxval=total).start() | ||
141 | pbar.update(current) | ||
138 | else: | 142 | else: |
139 | if x == 1: | 143 | if current == 1: |
140 | sys.stdout.write("Parsing .bb files, please wait...") | 144 | sys.stdout.write("Parsing .bb files, please wait...") |
141 | sys.stdout.flush() | 145 | sys.stdout.flush() |
142 | if x == y: | 146 | if current == total: |
143 | sys.stdout.write("done.") | 147 | sys.stdout.write("done.") |
144 | sys.stdout.flush() | 148 | sys.stdout.flush() |
145 | if x == y: | 149 | if current == total: |
146 | print(("\nParsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." | 150 | print(("\nParsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." |
147 | % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) | 151 | % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) |
148 | continue | 152 | continue |