summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/toasterui.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/ui/toasterui.py')
-rw-r--r--bitbake/lib/bb/ui/toasterui.py57
1 files changed, 27 insertions, 30 deletions
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py
index 767bfabe31..9c7e87dd1e 100644
--- a/bitbake/lib/bb/ui/toasterui.py
+++ b/bitbake/lib/bb/ui/toasterui.py
@@ -31,16 +31,12 @@ from bb.ui import uihelper
31from bb.ui.buildinfohelper import BuildInfoHelper 31from bb.ui.buildinfohelper import BuildInfoHelper
32 32
33import bb.msg 33import bb.msg
34import copy
35import fcntl
36import logging 34import logging
37import os 35import os
38import progressbar 36
39import signal 37# pylint: disable=invalid-name
40import struct 38# module properties for UI modules are read by bitbake and the contract should not be broken
41import sys 39
42import time
43import xmlrpclib
44 40
45featureSet = [bb.cooker.CookerFeatures.HOB_EXTRA_CACHES, bb.cooker.CookerFeatures.SEND_DEPENDS_TREE, bb.cooker.CookerFeatures.BASEDATASTORE_TRACKING, bb.cooker.CookerFeatures.SEND_SANITYEVENTS] 41featureSet = [bb.cooker.CookerFeatures.HOB_EXTRA_CACHES, bb.cooker.CookerFeatures.SEND_DEPENDS_TREE, bb.cooker.CookerFeatures.BASEDATASTORE_TRACKING, bb.cooker.CookerFeatures.SEND_SANITYEVENTS]
46 42
@@ -53,15 +49,15 @@ def _log_settings_from_server(server):
53 # Get values of variables which control our output 49 # Get values of variables which control our output
54 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 50 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
55 if error: 51 if error:
56 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error) 52 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s", error)
57 raise BaseException(error) 53 raise BaseException(error)
58 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) 54 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
59 if error: 55 if error:
60 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error) 56 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s", error)
61 raise BaseException(error) 57 raise BaseException(error)
62 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"]) 58 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"])
63 if error: 59 if error:
64 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error) 60 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s", error)
65 raise BaseException(error) 61 raise BaseException(error)
66 return includelogs, loglines, consolelogfile 62 return includelogs, loglines, consolelogfile
67 63
@@ -71,17 +67,17 @@ def main(server, eventHandler, params ):
71 67
72 console = logging.StreamHandler(sys.stdout) 68 console = logging.StreamHandler(sys.stdout)
73 format_str = "%(levelname)s: %(message)s" 69 format_str = "%(levelname)s: %(message)s"
74 format = bb.msg.BBLogFormatter(format_str) 70 formatter = bb.msg.BBLogFormatter(format_str)
75 bb.msg.addDefaultlogFilter(console) 71 bb.msg.addDefaultlogFilter(console)
76 console.setFormatter(format) 72 console.setFormatter(formatter)
77 logger.addHandler(console) 73 logger.addHandler(console)
78 logger.setLevel(logging.INFO) 74 logger.setLevel(logging.INFO)
79 75
80 includelogs, loglines, consolelogfile = _log_settings_from_server(server) 76 _, _, consolelogfile = _log_settings_from_server(server)
81 77
82 # verify and warn 78 # verify and warn
83 build_history_enabled = True 79 build_history_enabled = True
84 inheritlist, error = server.runCommand(["getVariable", "INHERIT"]) 80 inheritlist, _ = server.runCommand(["getVariable", "INHERIT"])
85 81
86 if not "buildhistory" in inheritlist.split(" "): 82 if not "buildhistory" in inheritlist.split(" "):
87 logger.warn("buildhistory is not enabled. Please enable INHERIT += \"buildhistory\" to see image details.") 83 logger.warn("buildhistory is not enabled. Please enable INHERIT += \"buildhistory\" to see image details.")
@@ -126,12 +122,15 @@ def main(server, eventHandler, params ):
126 122
127 helper.eventHandler(event) 123 helper.eventHandler(event)
128 124
125 # pylint: disable=protected-access
126 # the code will look into the protected variables of the event; no easy way around this
127
129 if isinstance(event, bb.event.BuildStarted): 128 if isinstance(event, bb.event.BuildStarted):
130 buildinfohelper.store_started_build(event) 129 buildinfohelper.store_started_build(event)
131 130
132 if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)): 131 if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)):
133 buildinfohelper.update_and_store_task(event) 132 buildinfohelper.update_and_store_task(event)
134 logger.warn("Logfile for task %s" % event.logfile) 133 logger.warn("Logfile for task %s", event.logfile)
135 continue 134 continue
136 135
137 if isinstance(event, bb.build.TaskBase): 136 if isinstance(event, bb.build.TaskBase):
@@ -143,17 +142,17 @@ def main(server, eventHandler, params ):
143 142
144 if isinstance(event, logging.LogRecord): 143 if isinstance(event, logging.LogRecord):
145 if event.levelno == -1: 144 if event.levelno == -1:
146 event.levelno = format.ERROR 145 event.levelno = formatter.ERROR
147 146
148 buildinfohelper.store_log_event(event) 147 buildinfohelper.store_log_event(event)
149 if event.levelno >= format.ERROR: 148 if event.levelno >= formatter.ERROR:
150 errors = errors + 1 149 errors = errors + 1
151 elif event.levelno == format.WARNING: 150 elif event.levelno == formatter.WARNING:
152 warnings = warnings + 1 151 warnings = warnings + 1
153 # For "normal" logging conditions, don't show note logs from tasks 152 # For "normal" logging conditions, don't show note logs from tasks
154 # but do show them if the user has changed the default log level to 153 # but do show them if the user has changed the default log level to
155 # include verbose/debug messages 154 # include verbose/debug messages
156 if event.taskpid != 0 and event.levelno <= format.NOTE: 155 if event.taskpid != 0 and event.levelno <= formatter.NOTE:
157 continue 156 continue
158 157
159 logger.handle(event) 158 logger.handle(event)
@@ -241,8 +240,8 @@ def main(server, eventHandler, params ):
241 240
242 if isinstance(event, (bb.event.BuildCompleted, bb.command.CommandFailed)): 241 if isinstance(event, (bb.event.BuildCompleted, bb.command.CommandFailed)):
243 242
244 errorcode = 0 243 errorcode = 0
245 if (isinstance(event, bb.command.CommandFailed)): 244 if isinstance(event, bb.command.CommandFailed):
246 errors += 1 245 errors += 1
247 errorcode = 1 246 errorcode = 1
248 logger.error("Command execution failed: %s", event.error) 247 logger.error("Command execution failed: %s", event.error)
@@ -251,7 +250,7 @@ def main(server, eventHandler, params ):
251 buildinfohelper.update_build_information(event, errors, warnings, taskfailures) 250 buildinfohelper.update_build_information(event, errors, warnings, taskfailures)
252 buildinfohelper.close(errorcode) 251 buildinfohelper.close(errorcode)
253 # mark the log output; controllers may kill the toasterUI after seeing this log 252 # mark the log output; controllers may kill the toasterUI after seeing this log
254 logger.info("ToasterUI build done 1, brbe: %s" % buildinfohelper.brbe ) 253 logger.info("ToasterUI build done 1, brbe: %s", buildinfohelper.brbe )
255 254
256 # we start a new build info 255 # we start a new build info
257 if buildinfohelper.brbe is not None: 256 if buildinfohelper.brbe is not None:
@@ -293,7 +292,7 @@ def main(server, eventHandler, params ):
293 elif event.type == "LicenseManifestPath": 292 elif event.type == "LicenseManifestPath":
294 buildinfohelper.store_license_manifest_path(event) 293 buildinfohelper.store_license_manifest_path(event)
295 else: 294 else:
296 logger.error("Unprocessed MetadataEvent %s " % str(event)) 295 logger.error("Unprocessed MetadataEvent %s ", str(event))
297 continue 296 continue
298 297
299 if isinstance(event, bb.cooker.CookerExit): 298 if isinstance(event, bb.cooker.CookerExit):
@@ -325,30 +324,28 @@ def main(server, eventHandler, params ):
325 pass 324 pass
326 except KeyboardInterrupt: 325 except KeyboardInterrupt:
327 main.shutdown = 1 326 main.shutdown = 1
328 pass
329 except Exception as e: 327 except Exception as e:
330 # print errors to log 328 # print errors to log
331 import traceback 329 import traceback
332 from pprint import pformat 330 from pprint import pformat
333 exception_data = traceback.format_exc() 331 exception_data = traceback.format_exc()
334 logger.error("%s\n%s" % (e, exception_data)) 332 logger.error("%s\n%s" , e, exception_data)
335 333
336 exc_type, exc_value, tb = sys.exc_info() 334 _, _, tb = sys.exc_info()
337 if tb is not None: 335 if tb is not None:
338 curr = tb 336 curr = tb
339 while curr is not None: 337 while curr is not None:
340 logger.warn("Error data dump %s\n%s\n" % (traceback.format_tb(curr,1), pformat(curr.tb_frame.f_locals))) 338 logger.warn("Error data dump %s\n%s\n" , traceback.format_tb(curr,1), pformat(curr.tb_frame.f_locals))
341 curr = curr.tb_next 339 curr = curr.tb_next
342 340
343 # save them to database, if possible; if it fails, we already logged to console. 341 # save them to database, if possible; if it fails, we already logged to console.
344 try: 342 try:
345 buildinfohelper.store_log_exception("%s\n%s" % (str(e), exception_data)) 343 buildinfohelper.store_log_exception("%s\n%s" % (str(e), exception_data))
346 except Exception as ce: 344 except Exception as ce:
347 logger.error("CRITICAL - Failed to to save toaster exception to the database: %s" % str(ce)) 345 logger.error("CRITICAL - Failed to to save toaster exception to the database: %s", str(ce))
348 346
349 # make sure we return with an error 347 # make sure we return with an error
350 return_value += 1 348 return_value += 1
351 pass
352 349
353 if interrupted: 350 if interrupted:
354 if return_value == 0: 351 if return_value == 0: