From f3acb135e723258bd4b6072d5737d52e13d47054 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Sun, 27 Jan 2013 15:41:20 -0800 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/ncurses.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/bb/ui/ncurses.py') diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py index 8524446d22..896ed01a78 100644 --- a/bitbake/lib/bb/ui/ncurses.py +++ b/bitbake/lib/bb/ui/ncurses.py @@ -230,15 +230,18 @@ class NCursesUI: shutdown = 0 try: - cmdline = server.runCommand(["getCmdLineAction"]) + cmdline, error = server.runCommand(["getCmdLineAction"]) if not cmdline: print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") return - elif not cmdline['action']: - print(cmdline['msg']) + elif error: + print("Error getting bitbake commandline: %s" % error) return - ret = server.runCommand(cmdline['action']) - if ret != True: + ret, error = server.runCommand(cmdline) + if error: + print("Error running command '%s': %s" % (cmdline, error)) + return + elif ret != True: print("Couldn't get default commandlind! %s" % ret) return except xmlrpclib.Fault as x: @@ -337,10 +340,14 @@ class NCursesUI: exitflag = True if shutdown == 1: mw.appendText("Second Keyboard Interrupt, stopping...\n") - server.runCommand(["stateStop"]) + _, error = server.runCommand(["stateStop"]) + if error: + print("Unable to cleanly stop: %s" % error) if shutdown == 0: mw.appendText("Keyboard Interrupt, closing down...\n") - server.runCommand(["stateShutdown"]) + _, error = server.runCommand(["stateShutdown"]) + if error: + print("Unable to cleanly shutdown: %s" % error) shutdown = shutdown + 1 pass -- cgit v1.2.3-54-g00ecf