summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.py
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2012-10-29 13:01:23 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-11-01 11:46:22 +0000
commitc1c20c02a0eb808a099bebfcc7e90188baa22ba4 (patch)
treefea4ff816120e77b9e8b5bc547703478387e067d /bitbake/lib/bb/ui/knotty.py
parent99fa251b5696dff77358d514175bbb08802a7a02 (diff)
downloadast2050-yocto-poky-c1c20c02a0eb808a099bebfcc7e90188baa22ba4.zip
ast2050-yocto-poky-c1c20c02a0eb808a099bebfcc7e90188baa22ba4.tar.gz
bitbake: command: add error to return of runCommand
Currently, command.py can return an error message from runCommand, due to being unable to run the command, yet few of our UIs (just hob) can handle it today. This can result in seeing a TypeError with traceback in certain rare circumstances. To resolve this, we need a clean way to get errors back from runCommand, without having to isinstance() the return value. This implements such a thing by making runCommand also return an error (or None if no error occurred). As runCommand now has a method of returning errors, we can also alter the getCmdLineAction bits such that the returned value is just the action, not an additional message. If a sync command wants to return an error, it raises CommandError(message), and the message will be passed to the caller appropriately. Example Usage: result, error = server.runCommand(...) if error: log.error('Unable to run command: %s' % error) return 1 (Bitbake rev: 717831b8315cb3904d9b590e633000bc897e8fb6) Signed-off-by: Christopher Larson <chris_larson@mentor.com> 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.py46
1 files changed, 32 insertions, 14 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 6ac3d85..b99a121 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -217,9 +217,19 @@ class TerminalFilter(object):
def main(server, eventHandler, tf = TerminalFilter):
# Get values of variables which control our output
- includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"])
- loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
- consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"])
+ includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
+ if error:
+ logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error)
+ return 1
+ loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
+ if error:
+ logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error)
+ return 1
+ consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"])
+ if error:
+ logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error)
+ return 1
+
if sys.stdin.isatty() and sys.stdout.isatty():
log_exec_tty = True
else:
@@ -240,19 +250,22 @@ def main(server, eventHandler, tf = TerminalFilter):
logger.addHandler(consolelog)
try:
- cmdline = server.runCommand(["getCmdLineAction"])
- if not cmdline:
+ cmdline, error = server.runCommand(["getCmdLineAction"])
+ if error:
+ logger.error("Unable to get bitbake commandline arguments: %s" % error)
+ return 1
+ elif not cmdline:
print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
return 1
- elif not cmdline['action']:
- print(cmdline['msg'])
+ ret, error = server.runCommand(cmdline)
+ if error:
+ logger.error("Command '%s' failed: %s" % (cmdline, error))
return 1
- ret = server.runCommand(cmdline['action'])
- if ret != True:
- print("Couldn't get default commandline! %s" % ret)
+ elif ret != True:
+ logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
return 1
except xmlrpclib.Fault as x:
- print("XMLRPC Fault getting commandline:\n %s" % x)
+ logger.error("XMLRPC Fault getting commandline:\n %s" % x)
return 1
parseprogress = None
@@ -447,14 +460,19 @@ def main(server, eventHandler, tf = TerminalFilter):
if ioerror.args[0] == 4:
pass
except KeyboardInterrupt:
+ import time
termfilter.clearFooter()
if main.shutdown == 1:
print("\nSecond Keyboard Interrupt, stopping...\n")
- server.runCommand(["stateStop"])
+ _, error = server.runCommand(["stateStop"])
+ if error:
+ logger.error("Unable to cleanly stop: %s" % error)
if main.shutdown == 0:
- interrupted = True
print("\nKeyboard Interrupt, closing down...\n")
- server.runCommand(["stateShutdown"])
+ interrupted = True
+ _, error = server.runCommand(["stateShutdown"])
+ if error:
+ logger.error("Unable to cleanly shutdown: %s" % error)
main.shutdown = main.shutdown + 1
pass
OpenPOWER on IntegriCloud