summaryrefslogtreecommitdiffstats
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-08 09:57:27 +0100
commit76feac37ceb68a850394e51dce8e36f1ec2c895d (patch)
treebc90e81add399a0098426c3d93db92553b0e02d2
parent465f93968f113ab32efc9da151078d481a9e08b9 (diff)
downloadpoky-76feac37ceb68a850394e51dce8e36f1ec2c895d.tar.gz
bitbake: 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. (Bitbake rev: db95cdef08e339dec7462bfde3ad7d75c1c60dd8) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbitbake/lib/bb/main.py9
-rw-r--r--bitbake/lib/bb/msg.py5
-rw-r--r--bitbake/lib/bb/ui/knotty.py57
3 files changed, 45 insertions, 26 deletions
diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index 283f29bb15..3fc3ff51e2 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -179,6 +179,9 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
179 parser.add_option("-D", "--debug", action="count", dest="debug", default=0, 179 parser.add_option("-D", "--debug", action="count", dest="debug", default=0,
180 help="Increase the debug level. You can specify this more than once.") 180 help="Increase the debug level. You can specify this more than once.")
181 181
182 parser.add_option("-q", "--quiet", action="store_true", dest="quiet", default=False,
183 help="Output less log message data to the terminal.")
184
182 parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False, 185 parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False,
183 help="Don't execute, just go through the motions.") 186 help="Don't execute, just go through the motions.")
184 187
@@ -279,6 +282,12 @@ class BitBakeConfigParameters(cookerdata.ConfigParameters):
279 282
280 options, targets = parser.parse_args(argv) 283 options, targets = parser.parse_args(argv)
281 284
285 if options.quiet and options.verbose:
286 parser.error("options --quiet and --verbose are mutually exclusive")
287
288 if options.quiet and options.debug:
289 parser.error("options --quiet and --debug are mutually exclusive")
290
282 # use configuration files from environment variables 291 # use configuration files from environment variables
283 if "BBPRECONF" in os.environ: 292 if "BBPRECONF" in os.environ:
284 options.prefile.append(os.environ["BBPRECONF"]) 293 options.prefile.append(os.environ["BBPRECONF"])
diff --git a/bitbake/lib/bb/msg.py b/bitbake/lib/bb/msg.py
index 8c3ab47623..b7c39fa133 100644
--- a/bitbake/lib/bb/msg.py
+++ b/bitbake/lib/bb/msg.py
@@ -182,9 +182,12 @@ def constructLogOptions():
182 debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1 182 debug_domains["BitBake.%s" % domainarg] = logging.DEBUG - dlevel + 1
183 return level, debug_domains 183 return level, debug_domains
184 184
185def addDefaultlogFilter(handler, cls = BBLogFilter): 185def addDefaultlogFilter(handler, cls = BBLogFilter, forcelevel=None):
186 level, debug_domains = constructLogOptions() 186 level, debug_domains = constructLogOptions()
187 187
188 if forcelevel is not None:
189 level = forcelevel
190
188 cls(handler, level, debug_domains) 191 cls(handler, level, debug_domains)
189 192
190# 193#
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index c245c22dc7..dbcb9c417b 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -161,7 +161,7 @@ class TerminalFilter(object):
161 cr = (25, 80) 161 cr = (25, 80)
162 return cr 162 return cr
163 163
164 def __init__(self, main, helper, console, errconsole, format): 164 def __init__(self, main, helper, console, errconsole, format, quiet):
165 self.main = main 165 self.main = main
166 self.helper = helper 166 self.helper = helper
167 self.cuu = None 167 self.cuu = None
@@ -169,6 +169,7 @@ class TerminalFilter(object):
169 self.interactive = sys.stdout.isatty() 169 self.interactive = sys.stdout.isatty()
170 self.footer_present = False 170 self.footer_present = False
171 self.lastpids = [] 171 self.lastpids = []
172 self.quiet = quiet
172 173
173 if not self.interactive: 174 if not self.interactive:
174 return 175 return
@@ -267,25 +268,26 @@ class TerminalFilter(object):
267 self.main_progress.update(self.helper.tasknumber_current) 268 self.main_progress.update(self.helper.tasknumber_current)
268 print('') 269 print('')
269 lines = 1 + int(len(content) / (self.columns + 1)) 270 lines = 1 + int(len(content) / (self.columns + 1))
270 for tasknum, task in enumerate(tasks[:(self.rows - 2)]): 271 if not self.quiet:
271 if isinstance(task, tuple): 272 for tasknum, task in enumerate(tasks[:(self.rows - 2)]):
272 pbar, progress, rate, start_time = task 273 if isinstance(task, tuple):
273 if not pbar.start_time: 274 pbar, progress, rate, start_time = task
274 pbar.start(False) 275 if not pbar.start_time:
275 if start_time: 276 pbar.start(False)
276 pbar.start_time = start_time 277 if start_time:
277 pbar.setmessage('%s:%s' % (tasknum, pbar.msg.split(':', 1)[1])) 278 pbar.start_time = start_time
278 if progress > -1: 279 pbar.setmessage('%s:%s' % (tasknum, pbar.msg.split(':', 1)[1]))
279 pbar.setextra(rate) 280 if progress > -1:
280 output = pbar.update(progress) 281 pbar.setextra(rate)
282 output = pbar.update(progress)
283 else:
284 output = pbar.update(1)
285 if not output or (len(output) <= pbar.term_width):
286 print('')
281 else: 287 else:
282 output = pbar.update(1) 288 content = "%s: %s" % (tasknum, task)
283 if not output or (len(output) <= pbar.term_width): 289 print(content)
284 print('') 290 lines = lines + 1 + int(len(content) / (self.columns + 1))
285 else:
286 content = "%s: %s" % (tasknum, task)
287 print(content)
288 lines = lines + 1 + int(len(content) / (self.columns + 1))
289 self.footer_present = lines 291 self.footer_present = lines
290 self.lastpids = runningpids[:] 292 self.lastpids = runningpids[:]
291 self.lastcount = self.helper.tasknumber_current 293 self.lastcount = self.helper.tasknumber_current
@@ -336,7 +338,10 @@ def main(server, eventHandler, params, tf = TerminalFilter):
336 errconsole = logging.StreamHandler(sys.stderr) 338 errconsole = logging.StreamHandler(sys.stderr)
337 format_str = "%(levelname)s: %(message)s" 339 format_str = "%(levelname)s: %(message)s"
338 format = bb.msg.BBLogFormatter(format_str) 340 format = bb.msg.BBLogFormatter(format_str)
339 bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut) 341 if params.options.quiet:
342 bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut, bb.msg.BBLogFormatter.WARNING)
343 else:
344 bb.msg.addDefaultlogFilter(console, bb.msg.BBLogFilterStdOut)
340 bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr) 345 bb.msg.addDefaultlogFilter(errconsole, bb.msg.BBLogFilterStdErr)
341 console.setFormatter(format) 346 console.setFormatter(format)
342 errconsole.setFormatter(format) 347 errconsole.setFormatter(format)
@@ -399,7 +404,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
399 warnings = 0 404 warnings = 0
400 taskfailures = [] 405 taskfailures = []
401 406
402 termfilter = tf(main, helper, console, errconsole, format) 407 termfilter = tf(main, helper, console, errconsole, format, params.options.quiet)
403 atexit.register(termfilter.finish) 408 atexit.register(termfilter.finish)
404 409
405 while True: 410 while True:
@@ -498,8 +503,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
498 continue 503 continue
499 504
500 parseprogress.finish() 505 parseprogress.finish()
501 print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." 506 if not params.options.quiet:
502 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) 507 print(("Parsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors."
508 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
503 continue 509 continue
504 510
505 if isinstance(event, bb.event.CacheLoadStarted): 511 if isinstance(event, bb.event.CacheLoadStarted):
@@ -510,7 +516,8 @@ def main(server, eventHandler, params, tf = TerminalFilter):
510 continue 516 continue
511 if isinstance(event, bb.event.CacheLoadCompleted): 517 if isinstance(event, bb.event.CacheLoadCompleted):
512 cacheprogress.finish() 518 cacheprogress.finish()
513 print("Loaded %d entries from dependency cache." % event.num_entries) 519 if not params.options.quiet:
520 print("Loaded %d entries from dependency cache." % event.num_entries)
514 continue 521 continue
515 522
516 if isinstance(event, bb.command.CommandFailed): 523 if isinstance(event, bb.command.CommandFailed):
@@ -670,7 +677,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
670 if return_value and errors: 677 if return_value and errors:
671 summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.", 678 summary += pluralise("\nSummary: There was %s ERROR message shown, returning a non-zero exit code.",
672 "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors) 679 "\nSummary: There were %s ERROR messages shown, returning a non-zero exit code.", errors)
673 if summary: 680 if summary and not params.options.quiet:
674 print(summary) 681 print(summary)
675 682
676 if interrupted: 683 if interrupted: