mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
bitbake: lib/bb/event: refactor printing events
We really ought to have just one place where the string representation of these events is produced. This doesn't take any real control away from the UI - if an alternative representation is desired, that can still be made. (Bitbake rev: cb15db2a799be6d8eab9a2a43a9a573f89229cff) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
eb7401d470
commit
21bb330f46
@@ -50,6 +50,8 @@ class CommandFailed(CommandExit):
|
|||||||
def __init__(self, message):
|
def __init__(self, message):
|
||||||
self.error = message
|
self.error = message
|
||||||
CommandExit.__init__(self, 1)
|
CommandExit.__init__(self, 1)
|
||||||
|
def __str__(self):
|
||||||
|
return "Command execution failed: %s" % self.error
|
||||||
|
|
||||||
class CommandError(Exception):
|
class CommandError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -521,6 +521,28 @@ class NoProvider(Event):
|
|||||||
def isRuntime(self):
|
def isRuntime(self):
|
||||||
return self._runtime
|
return self._runtime
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
msg = ''
|
||||||
|
if self._runtime:
|
||||||
|
r = "R"
|
||||||
|
else:
|
||||||
|
r = ""
|
||||||
|
|
||||||
|
extra = ''
|
||||||
|
if not self._reasons:
|
||||||
|
if self._close_matches:
|
||||||
|
extra = ". Close matches:\n %s" % '\n '.join(self._close_matches)
|
||||||
|
|
||||||
|
if self._dependees:
|
||||||
|
msg = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, self._item, ", ".join(self._dependees), r, extra)
|
||||||
|
else:
|
||||||
|
msg = "Nothing %sPROVIDES '%s'%s" % (r, self._item, extra)
|
||||||
|
if self._reasons:
|
||||||
|
for reason in self._reasons:
|
||||||
|
msg += '\n' + reason
|
||||||
|
return msg
|
||||||
|
|
||||||
|
|
||||||
class MultipleProviders(Event):
|
class MultipleProviders(Event):
|
||||||
"""Multiple Providers"""
|
"""Multiple Providers"""
|
||||||
|
|
||||||
@@ -548,6 +570,16 @@ class MultipleProviders(Event):
|
|||||||
"""
|
"""
|
||||||
return self._candidates
|
return self._candidates
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
msg = "Multiple providers are available for %s%s (%s)" % (self._is_runtime and "runtime " or "",
|
||||||
|
self._item,
|
||||||
|
", ".join(self._candidates))
|
||||||
|
rtime = ""
|
||||||
|
if self._is_runtime:
|
||||||
|
rtime = "R"
|
||||||
|
msg += "\nConsider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, self._item)
|
||||||
|
return msg
|
||||||
|
|
||||||
class ParseStarted(OperationStarted):
|
class ParseStarted(OperationStarted):
|
||||||
"""Recipe parsing for the runqueue has begun"""
|
"""Recipe parsing for the runqueue has begun"""
|
||||||
def __init__(self, total):
|
def __init__(self, total):
|
||||||
|
|||||||
@@ -2488,6 +2488,9 @@ class runQueueTaskFailed(runQueueEvent):
|
|||||||
runQueueEvent.__init__(self, task, stats, rq)
|
runQueueEvent.__init__(self, task, stats, rq)
|
||||||
self.exitcode = exitcode
|
self.exitcode = exitcode
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Task (%s) failed with exit code '%s'" % (self.taskstring, self.exitcode)
|
||||||
|
|
||||||
class sceneQueueTaskFailed(sceneQueueEvent):
|
class sceneQueueTaskFailed(sceneQueueEvent):
|
||||||
"""
|
"""
|
||||||
Event notifying a setscene task failed
|
Event notifying a setscene task failed
|
||||||
@@ -2496,6 +2499,9 @@ class sceneQueueTaskFailed(sceneQueueEvent):
|
|||||||
sceneQueueEvent.__init__(self, task, stats, rq)
|
sceneQueueEvent.__init__(self, task, stats, rq)
|
||||||
self.exitcode = exitcode
|
self.exitcode = exitcode
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return "Setscene task (%s) failed with exit code '%s' - real task will be run instead" % (self.taskstring, self.exitcode)
|
||||||
|
|
||||||
class sceneQueueComplete(sceneQueueEvent):
|
class sceneQueueComplete(sceneQueueEvent):
|
||||||
"""
|
"""
|
||||||
Event when all the sceneQueue tasks are complete
|
Event when all the sceneQueue tasks are complete
|
||||||
|
|||||||
@@ -560,7 +560,7 @@ def main(server, eventHandler, params, tf = TerminalFilter):
|
|||||||
return_value = event.exitcode
|
return_value = event.exitcode
|
||||||
if event.error:
|
if event.error:
|
||||||
errors = errors + 1
|
errors = errors + 1
|
||||||
logger.error("Command execution failed: %s", event.error)
|
logger.error(str(event))
|
||||||
main.shutdown = 2
|
main.shutdown = 2
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.command.CommandExit):
|
if isinstance(event, bb.command.CommandExit):
|
||||||
@@ -571,39 +571,16 @@ def main(server, eventHandler, params, tf = TerminalFilter):
|
|||||||
main.shutdown = 2
|
main.shutdown = 2
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.MultipleProviders):
|
if isinstance(event, bb.event.MultipleProviders):
|
||||||
logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "",
|
logger.info(str(event))
|
||||||
event._item,
|
|
||||||
", ".join(event._candidates))
|
|
||||||
rtime = ""
|
|
||||||
if event._is_runtime:
|
|
||||||
rtime = "R"
|
|
||||||
logger.info("consider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, event._item))
|
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.NoProvider):
|
if isinstance(event, bb.event.NoProvider):
|
||||||
if event._runtime:
|
|
||||||
r = "R"
|
|
||||||
else:
|
|
||||||
r = ""
|
|
||||||
|
|
||||||
extra = ''
|
|
||||||
if not event._reasons:
|
|
||||||
if event._close_matches:
|
|
||||||
extra = ". Close matches:\n %s" % '\n '.join(event._close_matches)
|
|
||||||
|
|
||||||
# For universe builds, only show these as warnings, not errors
|
# For universe builds, only show these as warnings, not errors
|
||||||
h = logger.warning
|
|
||||||
if not universe:
|
if not universe:
|
||||||
return_value = 1
|
return_value = 1
|
||||||
errors = errors + 1
|
errors = errors + 1
|
||||||
h = logger.error
|
logger.error(str(event))
|
||||||
|
|
||||||
if event._dependees:
|
|
||||||
h("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s", r, event._item, ", ".join(event._dependees), r, extra)
|
|
||||||
else:
|
else:
|
||||||
h("Nothing %sPROVIDES '%s'%s", r, event._item, extra)
|
logger.warning(str(event))
|
||||||
if event._reasons:
|
|
||||||
for reason in event._reasons:
|
|
||||||
h("%s", reason)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.runqueue.sceneQueueTaskStarted):
|
if isinstance(event, bb.runqueue.sceneQueueTaskStarted):
|
||||||
@@ -625,13 +602,11 @@ def main(server, eventHandler, params, tf = TerminalFilter):
|
|||||||
if isinstance(event, bb.runqueue.runQueueTaskFailed):
|
if isinstance(event, bb.runqueue.runQueueTaskFailed):
|
||||||
return_value = 1
|
return_value = 1
|
||||||
taskfailures.append(event.taskstring)
|
taskfailures.append(event.taskstring)
|
||||||
logger.error("Task (%s) failed with exit code '%s'",
|
logger.error(str(event))
|
||||||
event.taskstring, event.exitcode)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.runqueue.sceneQueueTaskFailed):
|
if isinstance(event, bb.runqueue.sceneQueueTaskFailed):
|
||||||
logger.warning("Setscene task (%s) failed with exit code '%s' - real task will be run instead",
|
logger.warning(str(event))
|
||||||
event.taskstring, event.exitcode)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.event.DepTreeGenerated):
|
if isinstance(event, bb.event.DepTreeGenerated):
|
||||||
|
|||||||
@@ -315,7 +315,7 @@ class NCursesUI:
|
|||||||
# also allow them to now exit with a single ^C
|
# also allow them to now exit with a single ^C
|
||||||
shutdown = 2
|
shutdown = 2
|
||||||
if isinstance(event, bb.command.CommandFailed):
|
if isinstance(event, bb.command.CommandFailed):
|
||||||
mw.appendText("Command execution failed: %s" % event.error)
|
mw.appendText(str(event))
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
exitflag = True
|
exitflag = True
|
||||||
if isinstance(event, bb.command.CommandExit):
|
if isinstance(event, bb.command.CommandExit):
|
||||||
|
|||||||
@@ -286,23 +286,7 @@ def main(server, eventHandler, params):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.event.NoProvider):
|
if isinstance(event, bb.event.NoProvider):
|
||||||
if event._runtime:
|
print(str(event))
|
||||||
r = "R"
|
|
||||||
else:
|
|
||||||
r = ""
|
|
||||||
|
|
||||||
extra = ''
|
|
||||||
if not event._reasons:
|
|
||||||
if event._close_matches:
|
|
||||||
extra = ". Close matches:\n %s" % '\n '.join(event._close_matches)
|
|
||||||
|
|
||||||
if event._dependees:
|
|
||||||
print("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, event._item, ", ".join(event._dependees), r, extra))
|
|
||||||
else:
|
|
||||||
print("Nothing %sPROVIDES '%s'%s" % (r, event._item, extra))
|
|
||||||
if event._reasons:
|
|
||||||
for reason in event._reasons:
|
|
||||||
print(reason)
|
|
||||||
|
|
||||||
_, error = server.runCommand(["stateShutdown"])
|
_, error = server.runCommand(["stateShutdown"])
|
||||||
if error:
|
if error:
|
||||||
@@ -310,7 +294,7 @@ def main(server, eventHandler, params):
|
|||||||
break
|
break
|
||||||
|
|
||||||
if isinstance(event, bb.command.CommandFailed):
|
if isinstance(event, bb.command.CommandFailed):
|
||||||
print("Command execution failed: %s" % event.error)
|
print(str(event))
|
||||||
return event.exitcode
|
return event.exitcode
|
||||||
|
|
||||||
if isinstance(event, bb.command.CommandExit):
|
if isinstance(event, bb.command.CommandExit):
|
||||||
|
|||||||
@@ -320,29 +320,13 @@ def main(server, eventHandler, params):
|
|||||||
if isinstance(event, bb.event.CacheLoadCompleted):
|
if isinstance(event, bb.event.CacheLoadCompleted):
|
||||||
continue
|
continue
|
||||||
if isinstance(event, bb.event.MultipleProviders):
|
if isinstance(event, bb.event.MultipleProviders):
|
||||||
logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "",
|
logger.info(str(event))
|
||||||
event._item,
|
|
||||||
", ".join(event._candidates))
|
|
||||||
logger.info("consider defining a PREFERRED_PROVIDER entry to match %s", event._item)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, bb.event.NoProvider):
|
if isinstance(event, bb.event.NoProvider):
|
||||||
errors = errors + 1
|
errors = errors + 1
|
||||||
if event._runtime:
|
text = str(event)
|
||||||
r = "R"
|
|
||||||
else:
|
|
||||||
r = ""
|
|
||||||
|
|
||||||
if event._dependees:
|
|
||||||
text = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)" % (r, event._item, ", ".join(event._dependees), r)
|
|
||||||
else:
|
|
||||||
text = "Nothing %sPROVIDES '%s'" % (r, event._item)
|
|
||||||
|
|
||||||
logger.error(text)
|
logger.error(text)
|
||||||
if event._reasons:
|
|
||||||
for reason in event._reasons:
|
|
||||||
logger.error("%s", reason)
|
|
||||||
text += reason
|
|
||||||
buildinfohelper.store_log_error(text)
|
buildinfohelper.store_log_error(text)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -364,8 +348,7 @@ def main(server, eventHandler, params):
|
|||||||
if isinstance(event, bb.runqueue.runQueueTaskFailed):
|
if isinstance(event, bb.runqueue.runQueueTaskFailed):
|
||||||
buildinfohelper.update_and_store_task(event)
|
buildinfohelper.update_and_store_task(event)
|
||||||
taskfailures.append(event.taskstring)
|
taskfailures.append(event.taskstring)
|
||||||
logger.error("Task (%s) failed with exit code '%s'",
|
logger.error(str(event))
|
||||||
event.taskstring, event.exitcode)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if isinstance(event, (bb.runqueue.sceneQueueTaskCompleted, bb.runqueue.sceneQueueTaskFailed)):
|
if isinstance(event, (bb.runqueue.sceneQueueTaskCompleted, bb.runqueue.sceneQueueTaskFailed)):
|
||||||
@@ -382,7 +365,7 @@ def main(server, eventHandler, params):
|
|||||||
if isinstance(event, bb.command.CommandFailed):
|
if isinstance(event, bb.command.CommandFailed):
|
||||||
errors += 1
|
errors += 1
|
||||||
errorcode = 1
|
errorcode = 1
|
||||||
logger.error("Command execution failed: %s", event.error)
|
logger.error(str(event))
|
||||||
elif isinstance(event, bb.event.BuildCompleted):
|
elif isinstance(event, bb.event.BuildCompleted):
|
||||||
buildinfohelper.scan_image_artifacts()
|
buildinfohelper.scan_image_artifacts()
|
||||||
buildinfohelper.clone_required_sdk_artifacts()
|
buildinfohelper.clone_required_sdk_artifacts()
|
||||||
|
|||||||
Reference in New Issue
Block a user