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-12-07 17:25:54 +0000
commit3b9a640f8d19cd50d64ae2722304ace80453149e (patch)
treec62c9a85e3dea9580d1d88b0579594c6e57ac524 /bitbake/lib/bb/ui/knotty.py
parenta2100b9b9d06c88f3791620729f64c39f8443f64 (diff)
downloadpoky-3b9a640f8d19cd50d64ae2722304ace80453149e.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: d1002e33e05d45a7e1bd65d79537419a4057e43a) 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 3799018fe3..8c63d74d9c 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -217,9 +217,19 @@ class TerminalFilter(object):
217def main(server, eventHandler, tf = TerminalFilter): 217def main(server, eventHandler, tf = TerminalFilter):
218 218
219 # Get values of variables which control our output 219 # Get values of variables which control our output
220 includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 220 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
221 loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) 221 if error:
222 consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"]) 222 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error)
223 return 1
224 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
225 if error:
226 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error)
227 return 1
228 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"])
229 if error:
230 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error)
231 return 1
232
223 if sys.stdin.isatty() and sys.stdout.isatty(): 233 if sys.stdin.isatty() and sys.stdout.isatty():
224 log_exec_tty = True 234 log_exec_tty = True
225 else: 235 else:
@@ -240,19 +250,22 @@ def main(server, eventHandler, tf = TerminalFilter):
240 logger.addHandler(consolelog) 250 logger.addHandler(consolelog)
241 251
242 try: 252 try:
243 cmdline = server.runCommand(["getCmdLineAction"]) 253 cmdline, error = server.runCommand(["getCmdLineAction"])
244 if not cmdline: 254 if error:
255 logger.error("Unable to get bitbake commandline arguments: %s" % error)
256 return 1
257 elif not cmdline:
245 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 258 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
246 return 1 259 return 1
247 elif not cmdline['action']: 260 ret, error = server.runCommand(cmdline)
248 print(cmdline['msg']) 261 if error:
262 logger.error("Command '%s' failed: %s" % (cmdline, error))
249 return 1 263 return 1
250 ret = server.runCommand(cmdline['action']) 264 elif ret != True:
251 if ret != True: 265 logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
252 print("Couldn't get default commandline! %s" % ret)
253 return 1 266 return 1
254 except xmlrpclib.Fault as x: 267 except xmlrpclib.Fault as x:
255 print("XMLRPC Fault getting commandline:\n %s" % x) 268 logger.error("XMLRPC Fault getting commandline:\n %s" % x)
256 return 1 269 return 1
257 270
258 parseprogress = None 271 parseprogress = None
@@ -447,14 +460,19 @@ def main(server, eventHandler, tf = TerminalFilter):
447 if ioerror.args[0] == 4: 460 if ioerror.args[0] == 4:
448 pass 461 pass
449 except KeyboardInterrupt: 462 except KeyboardInterrupt:
463 import time
450 termfilter.clearFooter() 464 termfilter.clearFooter()
451 if main.shutdown == 1: 465 if main.shutdown == 1:
452 print("\nSecond Keyboard Interrupt, stopping...\n") 466 print("\nSecond Keyboard Interrupt, stopping...\n")
453 server.runCommand(["stateStop"]) 467 _, error = server.runCommand(["stateStop"])
468 if error:
469 logger.error("Unable to cleanly stop: %s" % error)
454 if main.shutdown == 0: 470 if main.shutdown == 0:
455 interrupted = True
456 print("\nKeyboard Interrupt, closing down...\n") 471 print("\nKeyboard Interrupt, closing down...\n")
457 server.runCommand(["stateShutdown"]) 472 interrupted = True
473 _, error = server.runCommand(["stateShutdown"])
474 if error:
475 logger.error("Unable to cleanly shutdown: %s" % error)
458 main.shutdown = main.shutdown + 1 476 main.shutdown = main.shutdown + 1
459 pass 477 pass
460 478