summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-12-06 21:06:13 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:46 +0000
commit7ffd6f88b8b08e02665a3b29760e58c080322b44 (patch)
treee6abf2700e7cf5041763834d4e387c9d5f93120f /bitbake/lib/bb/ui/knotty.py
parent7ea3c969386f10a37bd713326060e9bb4dbc1f1e (diff)
downloadpoky-7ffd6f88b8b08e02665a3b29760e58c080322b44.tar.gz
knotty: shift non-interactive progress into a class
(Bitbake rev: c3d005cbbae3d56da9926666cfb1501c2bf96ea7) 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.py48
1 files changed, 33 insertions, 15 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 0c0cdf1fe7..00be2f8448 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -30,8 +30,32 @@ from bb import ui
30from bb.ui import uihelper 30from bb.ui import uihelper
31 31
32logger = logging.getLogger("BitBake") 32logger = logging.getLogger("BitBake")
33widgets = ['Parsing recipes: ', progressbar.Percentage(), ' ', 33widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
34 progressbar.Bar(), ' ', progressbar.ETA()] 34 progressbar.ETA()]
35
36class BBProgress(progressbar.ProgressBar):
37 def __init__(self, msg, maxval):
38 self.msg = msg
39 progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets)
40
41class NonInteractiveProgress(object):
42 fobj = sys.stdout
43
44 def __init__(self, msg, maxval):
45 self.msg = msg
46 self.maxval = maxval
47
48 def start(self):
49 self.fobj.write("%s..." % self.msg)
50 self.fobj.flush()
51 return self
52
53 def update(self, value):
54 pass
55
56 def finish(self):
57 self.fobj.write("done.\n")
58 self.fobj.flush()
35 59
36class BBLogFormatter(logging.Formatter): 60class BBLogFormatter(logging.Formatter):
37 """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is""" 61 """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is"""
@@ -77,7 +101,7 @@ def init(server, eventHandler):
77 print("XMLRPC Fault getting commandline:\n %s" % x) 101 print("XMLRPC Fault getting commandline:\n %s" % x)
78 return 1 102 return 1
79 103
80 pbar = None 104 parseprogress = None
81 interactive = os.isatty(sys.stdout.fileno()) 105 interactive = os.isatty(sys.stdout.fileno())
82 shutdown = 0 106 shutdown = 0
83 return_value = 0 107 return_value = 0
@@ -135,23 +159,17 @@ def init(server, eventHandler):
135 continue 159 continue
136 if isinstance(event, bb.event.ParseStarted): 160 if isinstance(event, bb.event.ParseStarted):
137 if interactive: 161 if interactive:
138 pbar = progressbar.ProgressBar(widgets=widgets, 162 progress = BBProgress
139 maxval=event.total).start()
140 else: 163 else:
141 sys.stdout.write("Parsing recipes...") 164 progress = NonInteractiveProgress
142 sys.stdout.flush() 165 parseprogress = progress("Parsing recipes", event.total).start()
143 continue 166 continue
144 if isinstance(event, bb.event.ParseProgress): 167 if isinstance(event, bb.event.ParseProgress):
145 if interactive: 168 parseprogress.update(event.current)
146 pbar.update(event.current)
147 continue 169 continue
148 if isinstance(event, bb.event.ParseCompleted): 170 if isinstance(event, bb.event.ParseCompleted):
149 if interactive: 171 parseprogress.finish()
150 pbar.update(pbar.maxval) 172 print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
151 else:
152 sys.stdout.write("done.\n")
153 sys.stdout.flush()
154 print(("\nParsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
155 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) 173 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
156 continue 174 continue
157 175