From 9ffbd9fe27e25a458b09631c503f4ef96632e334 Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Thu, 18 Nov 2010 21:15:07 -0700 Subject: Experimental usage of the 'progressbar' module (Bitbake rev: 64feb03bc2accecb49033df65e0a939ef5ab5986) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/knotty.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'bitbake/lib/bb/ui') 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 import itertools import xmlrpclib import logging +import progressbar from bb import ui from bb.ui import uihelper logger = logging.getLogger("BitBake") -parsespin = itertools.cycle( r'|/-\\' ) +widgets = ['Parsing recipes: ', progressbar.Percentage(), ' ', + progressbar.Bar(), ' ', progressbar.ETA()] class BBLogFormatter(logging.Formatter): """Formatter which ensures that our 'plain' messages (logging.INFO + 1) are used as is""" @@ -75,6 +77,7 @@ def init(server, eventHandler): print("XMLRPC Fault getting commandline:\n %s" % x) return 1 + pbar = None shutdown = 0 return_value = 0 while True: @@ -130,19 +133,20 @@ def init(server, eventHandler): logger.info(event._message) continue if isinstance(event, bb.event.ParseProgress): - x = event.sofar - y = event.total + current, total = event.sofar, event.total if os.isatty(sys.stdout.fileno()): - sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( next(parsespin), x, y, x*100//y ) ) - sys.stdout.flush() + if not pbar: + pbar = progressbar.ProgressBar(widgets=widgets, + maxval=total).start() + pbar.update(current) else: - if x == 1: + if current == 1: sys.stdout.write("Parsing .bb files, please wait...") sys.stdout.flush() - if x == y: + if current == total: sys.stdout.write("done.") sys.stdout.flush() - if x == y: + if current == total: 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))) continue -- cgit v1.2.3-54-g00ecf