summaryrefslogtreecommitdiffstats
path: root/lib/bb/ui
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-06-23 22:59:10 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-05 13:38:16 +0100
commitdb95cdef08e339dec7462bfde3ad7d75c1c60dd8 (patch)
tree5b3fe5328e35c6d97fbe6e15a8e8a1a18a98de6d /lib/bb/ui
parentde682015a3fefeff36ddc4197641a700f3fb558d (diff)
downloadbitbake-contrib-db95cdef08e339dec7462bfde3ad7d75c1c60dd8.tar.gz
knotty: add quiet output mode
Quiet output mode disables printing most messages (below warnings) to the console; however these messages still go to the console log file. This is primarily for cases where bitbake is being launched interactively from some other process, but where full console output is not needed. Because of the need to keep logging all normal events to the console log, this functionality was implemented within the knotty UI rather than in bb.msg (where verbose mode is implemented). We don't currently have a means of registering command line options from the UI end, thus the option actually has to be registered in main.py regardless of the UI, however I didn't feel like it was worth setting up such a mechanism just for this option. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/ui')
-rw-r--r--lib/bb/ui/knotty.py57
1 files changed, 32 insertions, 25 deletions
diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index c245c22dc..dbcb9c417 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -161,7 +161,7 @@ class TerminalFilter(object):
cr = (25, 80)
return cr
- def __init__(self, main, helper, console, errconsole, format):
+ def __init__(self, main, helper, console, errconsole, format, quiet):
self.main = main
self.helper = helper
self.cuu = None
@@ -169,6 +169,7 @@ class TerminalFilter(object):
self.interactive = sys.stdout.isatty()
self.footer_present = False
self.lastpids = []
+ self.quiet = quiet
if not self.interactive:
return
@@ -267,25 +268,26 @@ class TerminalFilter(object):
self.main_progress.update(self.helper.tasknumber_current)
print('')
lines = 1 + int(len(content) / (self.columns + 1))
- for tasknum, task in enumerate(tasks[:(self.rows - 2)]):
- if isinstance(task, tuple):
- pbar, progress, rate, start_time = task
- if not pbar.start_time:
- pbar.start(False)
- if start_time:
- pbar.start_time = start_time
- pbar.setmessage('%s:%s' % (tasknum, pbar.msg.split(':', 1)[1]))
- if progress > -1:
- pbar.setextra(rate)
- output = pbar.update(progress)
+ if not self.quiet:
+ for tasknum, task in enumerate(tasks[:(self.rows - 2)]):
+ if isinstance(task, tuple):
+ pbar, progress, rate, start_time = task
+ if not pbar.start_time:
+ pbar.start(False)
+ if start_time:
+ pbar.start_time = start_time
+ pbar.setmessage('%s:%s' % (tasknum, pbar.msg.split(':', 1)[1]))
+ if progress > -1:
+ pbar.setextra(rate)
+ output = pbar.update(progress)
+ else:
+ output = pbar.update(1)
+ if not output or (len(output) <= pbar.term_width):
+ print('')
else:
- output = pbar.update(1)
- if not output or (len(output) <= pbar.term_width):
- print('')
- else:
- content = "%s: %s" % (tasknum, task)
- print(content)
- lines = lines + 1 + int(len(content) / (self.columns + 1))
+ content = "%s: %s" % (tasknum, task)
+ print(content)
+ lines = lines + 1 + int(len(content) / (self.columns + 1))
self.footer_present = lines
self.lastpids = runningpids[:]
self.lastcount = self.helper.tasknumber_current
@@ -336,7 +338,10 @@ def main(server, eventHandler, params, tf = TerminalFilter):
errconsole = logging.StreamHandler(sys.stderr)
format_str = "%(levelname)s: %(message)s"
format = bb.msg.BBLogFormatter(format_str)
- bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
+ if params.options.quiet:
+ bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, bb.msg.BBLogFormatter.WARNING)
+ else:
+ bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)
console.setFormatter(format)
errconsole.setFormatter(format)
@@ -399,7 +404,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
warnings = 0
taskfailures = []
- termfilter = tf(main, helper, console, errconsole, format)
+ termfilter = tf(main, helper, console, errconsole, format, params.options.quiet)
atexit.register(termfilter.finish)
while True:
@@ -498,8 +503,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
continue
parseprogress.finish()
- print(("Parsing 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)))
+ if not params.options.quiet:
+ print(("Parsing 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
if isinstance(event, bb.event.CacheLoadStarted):
@@ -510,7 +516,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
continue
if isinstance(event, bb.event.CacheLoadCompleted):
cacheprogress.finish()
- print("Loaded %d entries from dependency cache." % event.num_entries)
+ if not params.options.quiet:
+ print("Loaded %d entries from dependency cache." % event.num_entries)
continue
if isinstance(event, bb.command.CommandFailed):
@@ -670,7 +677,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
if return_value and errors:
summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.",
"\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors)
- if summary:
+ if summary and not params.options.quiet:
print(summary)
if interrupted: