diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-07-19 11:56:03 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-07-21 08:41:12 +0100 |
commit | 21bb330f4632ae9e8dd9eaff2879bcd24f9cf194 (patch) | |
tree | 476a3ff0b5d7fc0f89fafc0cba2b720a6e6b5f3e /bitbake | |
parent | eb7401d47087ba2347dcf780a0d07969bed4c072 (diff) | |
download | poky-21bb330f4632ae9e8dd9eaff2879bcd24f9cf194.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/command.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/event.py | 32 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 37 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/ncurses.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/taskexp.py | 20 | ||||
-rw-r--r-- | bitbake/lib/bb/ui/toasterui.py | 25 |
7 files changed, 53 insertions, 71 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index c06ab072ad..05803d6af0 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -50,6 +50,8 @@ class CommandFailed(CommandExit): | |||
50 | def __init__(self, message): | 50 | def __init__(self, message): |
51 | self.error = message | 51 | self.error = message |
52 | CommandExit.__init__(self, 1) | 52 | CommandExit.__init__(self, 1) |
53 | def __str__(self): | ||
54 | return "Command execution failed: %s" % self.error | ||
53 | 55 | ||
54 | class CommandError(Exception): | 56 | class CommandError(Exception): |
55 | pass | 57 | pass |
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index 92ee3e92d4..59cca61424 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -521,6 +521,28 @@ class NoProvider(Event): | |||
521 | def isRuntime(self): | 521 | def isRuntime(self): |
522 | return self._runtime | 522 | return self._runtime |
523 | 523 | ||
524 | def __str__(self): | ||
525 | msg = '' | ||
526 | if self._runtime: | ||
527 | r = "R" | ||
528 | else: | ||
529 | r = "" | ||
530 | |||
531 | extra = '' | ||
532 | if not self._reasons: | ||
533 | if self._close_matches: | ||
534 | extra = ". Close matches:\n %s" % '\n '.join(self._close_matches) | ||
535 | |||
536 | if self._dependees: | ||
537 | msg = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, self._item, ", ".join(self._dependees), r, extra) | ||
538 | else: | ||
539 | msg = "Nothing %sPROVIDES '%s'%s" % (r, self._item, extra) | ||
540 | if self._reasons: | ||
541 | for reason in self._reasons: | ||
542 | msg += '\n' + reason | ||
543 | return msg | ||
544 | |||
545 | |||
524 | class MultipleProviders(Event): | 546 | class MultipleProviders(Event): |
525 | """Multiple Providers""" | 547 | """Multiple Providers""" |
526 | 548 | ||
@@ -548,6 +570,16 @@ class MultipleProviders(Event): | |||
548 | """ | 570 | """ |
549 | return self._candidates | 571 | return self._candidates |
550 | 572 | ||
573 | def __str__(self): | ||
574 | msg = "Multiple providers are available for %s%s (%s)" % (self._is_runtime and "runtime " or "", | ||
575 | self._item, | ||
576 | ", ".join(self._candidates)) | ||
577 | rtime = "" | ||
578 | if self._is_runtime: | ||
579 | rtime = "R" | ||
580 | msg += "\nConsider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, self._item) | ||
581 | return msg | ||
582 | |||
551 | class ParseStarted(OperationStarted): | 583 | class ParseStarted(OperationStarted): |
552 | """Recipe parsing for the runqueue has begun""" | 584 | """Recipe parsing for the runqueue has begun""" |
553 | def __init__(self, total): | 585 | def __init__(self, total): |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 21520d3d6a..7dd964d1c4 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -2488,6 +2488,9 @@ class runQueueTaskFailed(runQueueEvent): | |||
2488 | runQueueEvent.__init__(self, task, stats, rq) | 2488 | runQueueEvent.__init__(self, task, stats, rq) |
2489 | self.exitcode = exitcode | 2489 | self.exitcode = exitcode |
2490 | 2490 | ||
2491 | def __str__(self): | ||
2492 | return "Task (%s) failed with exit code '%s'" % (self.taskstring, self.exitcode) | ||
2493 | |||
2491 | class sceneQueueTaskFailed(sceneQueueEvent): | 2494 | class sceneQueueTaskFailed(sceneQueueEvent): |
2492 | """ | 2495 | """ |
2493 | Event notifying a setscene task failed | 2496 | Event notifying a setscene task failed |
@@ -2496,6 +2499,9 @@ class sceneQueueTaskFailed(sceneQueueEvent): | |||
2496 | sceneQueueEvent.__init__(self, task, stats, rq) | 2499 | sceneQueueEvent.__init__(self, task, stats, rq) |
2497 | self.exitcode = exitcode | 2500 | self.exitcode = exitcode |
2498 | 2501 | ||
2502 | def __str__(self): | ||
2503 | return "Setscene task (%s) failed with exit code '%s' - real task will be run instead" % (self.taskstring, self.exitcode) | ||
2504 | |||
2499 | class sceneQueueComplete(sceneQueueEvent): | 2505 | class sceneQueueComplete(sceneQueueEvent): |
2500 | """ | 2506 | """ |
2501 | Event when all the sceneQueue tasks are complete | 2507 | Event when all the sceneQueue tasks are complete |
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index 1aa5ebb287..c3019822c4 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py | |||
@@ -560,7 +560,7 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
560 | return_value = event.exitcode | 560 | return_value = event.exitcode |
561 | if event.error: | 561 | if event.error: |
562 | errors = errors + 1 | 562 | errors = errors + 1 |
563 | logger.error("Command execution failed: %s", event.error) | 563 | logger.error(str(event)) |
564 | main.shutdown = 2 | 564 | main.shutdown = 2 |
565 | continue | 565 | continue |
566 | if isinstance(event, bb.command.CommandExit): | 566 | if isinstance(event, bb.command.CommandExit): |
@@ -571,39 +571,16 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
571 | main.shutdown = 2 | 571 | main.shutdown = 2 |
572 | continue | 572 | continue |
573 | if isinstance(event, bb.event.MultipleProviders): | 573 | if isinstance(event, bb.event.MultipleProviders): |
574 | logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "", | 574 | logger.info(str(event)) |
575 | event._item, | ||
576 | ", ".join(event._candidates)) | ||
577 | rtime = "" | ||
578 | if event._is_runtime: | ||
579 | rtime = "R" | ||
580 | logger.info("consider defining a PREFERRED_%sPROVIDER entry to match %s" % (rtime, event._item)) | ||
581 | continue | 575 | continue |
582 | if isinstance(event, bb.event.NoProvider): | 576 | if isinstance(event, bb.event.NoProvider): |
583 | if event._runtime: | ||
584 | r = "R" | ||
585 | else: | ||
586 | r = "" | ||
587 | |||
588 | extra = '' | ||
589 | if not event._reasons: | ||
590 | if event._close_matches: | ||
591 | extra = ". Close matches:\n %s" % '\n '.join(event._close_matches) | ||
592 | |||
593 | # For universe builds, only show these as warnings, not errors | 577 | # For universe builds, only show these as warnings, not errors |
594 | h = logger.warning | ||
595 | if not universe: | 578 | if not universe: |
596 | return_value = 1 | 579 | return_value = 1 |
597 | errors = errors + 1 | 580 | errors = errors + 1 |
598 | h = logger.error | 581 | logger.error(str(event)) |
599 | |||
600 | if event._dependees: | ||
601 | h("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s", r, event._item, ", ".join(event._dependees), r, extra) | ||
602 | else: | 582 | else: |
603 | h("Nothing %sPROVIDES '%s'%s", r, event._item, extra) | 583 | logger.warning(str(event)) |
604 | if event._reasons: | ||
605 | for reason in event._reasons: | ||
606 | h("%s", reason) | ||
607 | continue | 584 | continue |
608 | 585 | ||
609 | if isinstance(event, bb.runqueue.sceneQueueTaskStarted): | 586 | if isinstance(event, bb.runqueue.sceneQueueTaskStarted): |
@@ -625,13 +602,11 @@ def main(server, eventHandler, params, tf = TerminalFilter): | |||
625 | if isinstance(event, bb.runqueue.runQueueTaskFailed): | 602 | if isinstance(event, bb.runqueue.runQueueTaskFailed): |
626 | return_value = 1 | 603 | return_value = 1 |
627 | taskfailures.append(event.taskstring) | 604 | taskfailures.append(event.taskstring) |
628 | logger.error("Task (%s) failed with exit code '%s'", | 605 | logger.error(str(event)) |
629 | event.taskstring, event.exitcode) | ||
630 | continue | 606 | continue |
631 | 607 | ||
632 | if isinstance(event, bb.runqueue.sceneQueueTaskFailed): | 608 | if isinstance(event, bb.runqueue.sceneQueueTaskFailed): |
633 | logger.warning("Setscene task (%s) failed with exit code '%s' - real task will be run instead", | 609 | logger.warning(str(event)) |
634 | event.taskstring, event.exitcode) | ||
635 | continue | 610 | continue |
636 | 611 | ||
637 | if isinstance(event, bb.event.DepTreeGenerated): | 612 | if isinstance(event, bb.event.DepTreeGenerated): |
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py index ca845a32ad..8690c529cc 100644 --- a/bitbake/lib/bb/ui/ncurses.py +++ b/bitbake/lib/bb/ui/ncurses.py | |||
@@ -315,7 +315,7 @@ class NCursesUI: | |||
315 | # also allow them to now exit with a single ^C | 315 | # also allow them to now exit with a single ^C |
316 | shutdown = 2 | 316 | shutdown = 2 |
317 | if isinstance(event, bb.command.CommandFailed): | 317 | if isinstance(event, bb.command.CommandFailed): |
318 | mw.appendText("Command execution failed: %s" % event.error) | 318 | mw.appendText(str(event)) |
319 | time.sleep(2) | 319 | time.sleep(2) |
320 | exitflag = True | 320 | exitflag = True |
321 | if isinstance(event, bb.command.CommandExit): | 321 | if isinstance(event, bb.command.CommandExit): |
diff --git a/bitbake/lib/bb/ui/taskexp.py b/bitbake/lib/bb/ui/taskexp.py index 9d14ecefaf..0d0f9f5a40 100644 --- a/bitbake/lib/bb/ui/taskexp.py +++ b/bitbake/lib/bb/ui/taskexp.py | |||
@@ -286,23 +286,7 @@ def main(server, eventHandler, params): | |||
286 | continue | 286 | continue |
287 | 287 | ||
288 | if isinstance(event, bb.event.NoProvider): | 288 | if isinstance(event, bb.event.NoProvider): |
289 | if event._runtime: | 289 | print(str(event)) |
290 | r = "R" | ||
291 | else: | ||
292 | r = "" | ||
293 | |||
294 | extra = '' | ||
295 | if not event._reasons: | ||
296 | if event._close_matches: | ||
297 | extra = ". Close matches:\n %s" % '\n '.join(event._close_matches) | ||
298 | |||
299 | if event._dependees: | ||
300 | print("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, event._item, ", ".join(event._dependees), r, extra)) | ||
301 | else: | ||
302 | print("Nothing %sPROVIDES '%s'%s" % (r, event._item, extra)) | ||
303 | if event._reasons: | ||
304 | for reason in event._reasons: | ||
305 | print(reason) | ||
306 | 290 | ||
307 | _, error = server.runCommand(["stateShutdown"]) | 291 | _, error = server.runCommand(["stateShutdown"]) |
308 | if error: | 292 | if error: |
@@ -310,7 +294,7 @@ def main(server, eventHandler, params): | |||
310 | break | 294 | break |
311 | 295 | ||
312 | if isinstance(event, bb.command.CommandFailed): | 296 | if isinstance(event, bb.command.CommandFailed): |
313 | print("Command execution failed: %s" % event.error) | 297 | print(str(event)) |
314 | return event.exitcode | 298 | return event.exitcode |
315 | 299 | ||
316 | if isinstance(event, bb.command.CommandExit): | 300 | if isinstance(event, bb.command.CommandExit): |
diff --git a/bitbake/lib/bb/ui/toasterui.py b/bitbake/lib/bb/ui/toasterui.py index 71f04fa5ce..88cec37592 100644 --- a/bitbake/lib/bb/ui/toasterui.py +++ b/bitbake/lib/bb/ui/toasterui.py | |||
@@ -320,29 +320,13 @@ def main(server, eventHandler, params): | |||
320 | if isinstance(event, bb.event.CacheLoadCompleted): | 320 | if isinstance(event, bb.event.CacheLoadCompleted): |
321 | continue | 321 | continue |
322 | if isinstance(event, bb.event.MultipleProviders): | 322 | if isinstance(event, bb.event.MultipleProviders): |
323 | logger.info("multiple providers are available for %s%s (%s)", event._is_runtime and "runtime " or "", | 323 | logger.info(str(event)) |
324 | event._item, | ||
325 | ", ".join(event._candidates)) | ||
326 | logger.info("consider defining a PREFERRED_PROVIDER entry to match %s", event._item) | ||
327 | continue | 324 | continue |
328 | 325 | ||
329 | if isinstance(event, bb.event.NoProvider): | 326 | if isinstance(event, bb.event.NoProvider): |
330 | errors = errors + 1 | 327 | errors = errors + 1 |
331 | if event._runtime: | 328 | text = str(event) |
332 | r = "R" | ||
333 | else: | ||
334 | r = "" | ||
335 | |||
336 | if event._dependees: | ||
337 | text = "Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)" % (r, event._item, ", ".join(event._dependees), r) | ||
338 | else: | ||
339 | text = "Nothing %sPROVIDES '%s'" % (r, event._item) | ||
340 | |||
341 | logger.error(text) | 329 | logger.error(text) |
342 | if event._reasons: | ||
343 | for reason in event._reasons: | ||
344 | logger.error("%s", reason) | ||
345 | text += reason | ||
346 | buildinfohelper.store_log_error(text) | 330 | buildinfohelper.store_log_error(text) |
347 | continue | 331 | continue |
348 | 332 | ||
@@ -364,8 +348,7 @@ def main(server, eventHandler, params): | |||
364 | if isinstance(event, bb.runqueue.runQueueTaskFailed): | 348 | if isinstance(event, bb.runqueue.runQueueTaskFailed): |
365 | buildinfohelper.update_and_store_task(event) | 349 | buildinfohelper.update_and_store_task(event) |
366 | taskfailures.append(event.taskstring) | 350 | taskfailures.append(event.taskstring) |
367 | logger.error("Task (%s) failed with exit code '%s'", | 351 | logger.error(str(event)) |
368 | event.taskstring, event.exitcode) | ||
369 | continue | 352 | continue |
370 | 353 | ||
371 | if isinstance(event, (bb.runqueue.sceneQueueTaskCompleted, bb.runqueue.sceneQueueTaskFailed)): | 354 | if isinstance(event, (bb.runqueue.sceneQueueTaskCompleted, bb.runqueue.sceneQueueTaskFailed)): |
@@ -382,7 +365,7 @@ def main(server, eventHandler, params): | |||
382 | if isinstance(event, bb.command.CommandFailed): | 365 | if isinstance(event, bb.command.CommandFailed): |
383 | errors += 1 | 366 | errors += 1 |
384 | errorcode = 1 | 367 | errorcode = 1 |
385 | logger.error("Command execution failed: %s", event.error) | 368 | logger.error(str(event)) |
386 | elif isinstance(event, bb.event.BuildCompleted): | 369 | elif isinstance(event, bb.event.BuildCompleted): |
387 | buildinfohelper.scan_image_artifacts() | 370 | buildinfohelper.scan_image_artifacts() |
388 | buildinfohelper.clone_required_sdk_artifacts() | 371 | buildinfohelper.clone_required_sdk_artifacts() |