mirror of
https://git.yoctoproject.org/poky
synced 2026-06-02 01:19:52 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
7ea3c96938
commit
7ffd6f88b8
+33
-15
@@ -30,8 +30,32 @@ from bb import ui
|
|||||||
from bb.ui import uihelper
|
from bb.ui import uihelper
|
||||||
|
|
||||||
logger = logging.getLogger("BitBake")
|
logger = logging.getLogger("BitBake")
|
||||||
widgets = ['Parsing recipes: ', progressbar.Percentage(), ' ',
|
widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
|
||||||
progressbar.Bar(), ' ', progressbar.ETA()]
|
progressbar.ETA()]
|
||||||
|
|
||||||
|
class BBProgress(progressbar.ProgressBar):
|
||||||
|
def __init__(self, msg, maxval):
|
||||||
|
self.msg = msg
|
||||||
|
progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets)
|
||||||
|
|
||||||
|
class NonInteractiveProgress(object):
|
||||||
|
fobj = sys.stdout
|
||||||
|
|
||||||
|
def __init__(self, msg, maxval):
|
||||||
|
self.msg = msg
|
||||||
|
self.maxval = maxval
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
self.fobj.write("%s..." % self.msg)
|
||||||
|
self.fobj.flush()
|
||||||
|
return self
|
||||||
|
|
||||||
|
def update(self, value):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def finish(self):
|
||||||
|
self.fobj.write("done.\n")
|
||||||
|
self.fobj.flush()
|
||||||
|
|
||||||
class BBLogFormatter(logging.Formatter):
|
class BBLogFormatter(logging.Formatter):
|
||||||
"""Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is"""
|
"""Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is"""
|
||||||
@@ -77,7 +101,7 @@ def init(server, eventHandler):
|
|||||||
print("XMLRPC Fault getting commandline:\n %s" % x)
|
print("XMLRPC Fault getting commandline:\n %s" % x)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
pbar = None
|
parseprogress = None
|
||||||
interactive = os.isatty(sys.stdout.fileno())
|
interactive = os.isatty(sys.stdout.fileno())
|
||||||
shutdown = 0
|
shutdown = 0
|
||||||
return_value = 0
|
return_value = 0
|
||||||
@@ -135,23 +159,17 @@ def init(server, eventHandler):
|
|||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.ParseStarted):
|
if isinstance(event, bb.event.ParseStarted):
|
||||||
if interactive:
|
if interactive:
|
||||||
pbar = progressbar.ProgressBar(widgets=widgets,
|
progress = BBProgress
|
||||||
maxval=event.total).start()
|
|
||||||
else:
|
else:
|
||||||
sys.stdout.write("Parsing recipes...")
|
progress = NonInteractiveProgress
|
||||||
sys.stdout.flush()
|
parseprogress = progress("Parsing recipes", event.total).start()
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.ParseProgress):
|
if isinstance(event, bb.event.ParseProgress):
|
||||||
if interactive:
|
parseprogress.update(event.current)
|
||||||
pbar.update(event.current)
|
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.ParseCompleted):
|
if isinstance(event, bb.event.ParseCompleted):
|
||||||
if interactive:
|
parseprogress.finish()
|
||||||
pbar.update(pbar.maxval)
|
print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
|
||||||
else:
|
|
||||||
sys.stdout.write("done.\n")
|
|
||||||
sys.stdout.flush()
|
|
||||||
print(("\nParsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
|
|
||||||
% ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
|
% ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user