summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-02 12:30:20 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-09-02 16:01:05 +0100
commita6709152e9788418e6c9431851437eb8ec4c6b46 (patch)
treed0c080d06de37c7ecf4b04ec108bc34c5fc09d76 /bitbake/lib/bb/ui/knotty.py
parentd38276f55c1b97251e6847401f84a6f6dac47b87 (diff)
downloadpoky-a6709152e9788418e6c9431851437eb8ec4c6b46.tar.gz
bitbake: process/knotty: Improve early exception handling
The new server startup code means exceptions can happen when we aren't setup to show them to the user correctly, leading to ugly tracebacks. Add in some special case handling of BBHandledException to at least ensure that common case doesn't traceback and the user sees meaningful output. In the future, the logging setup can likely be improved, as can the way runCommand handles exceptions, they all should likely become real exceptions again on the UI side. [YOCTO #14022] [YOCTO #14033] (Bitbake rev: 6059d0e77f60ddb679049bd34478f41b1ab7995d) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/knotty.py')
-rw-r--r--bitbake/lib/bb/ui/knotty.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index a3507afb7c..a91e4fd15c 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -380,14 +380,27 @@ _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.Lo
380 "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent", 380 "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent",
381 "bb.build.TaskProgress", "bb.event.ProcessStarted", "bb.event.ProcessProgress", "bb.event.ProcessFinished"] 381 "bb.build.TaskProgress", "bb.event.ProcessStarted", "bb.event.ProcessProgress", "bb.event.ProcessFinished"]
382 382
383def drain_events_errorhandling(eventHandler):
384 # We don't have logging setup, we do need to show any events we see before exiting
385 event = True
386 logger = bb.msg.logger_create('bitbake', sys.stdout)
387 while event:
388 event = eventHandler.waitEvent(0)
389 if isinstance(event, logging.LogRecord):
390 logger.handle(event)
391
383def main(server, eventHandler, params, tf = TerminalFilter): 392def main(server, eventHandler, params, tf = TerminalFilter):
384 393
385 if not params.observe_only: 394 try:
386 params.updateToServer(server, os.environ.copy()) 395 if not params.observe_only:
396 params.updateToServer(server, os.environ.copy())
387 397
388 includelogs, loglines, consolelogfile, logconfigfile = _log_settings_from_server(server, params.observe_only) 398 includelogs, loglines, consolelogfile, logconfigfile = _log_settings_from_server(server, params.observe_only)
389 399
390 loglevel, _ = bb.msg.constructLogOptions() 400 loglevel, _ = bb.msg.constructLogOptions()
401 except bb.BBHandledException:
402 drain_events_errorhandling(eventHandler)
403 return 1
391 404
392 if params.options.quiet == 0: 405 if params.options.quiet == 0:
393 console_loglevel = loglevel 406 console_loglevel = loglevel