From 717831b8315cb3904d9b590e633000bc897e8fb6 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Mon, 29 Oct 2012 13:01:23 -0700 Subject: 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 Signed-off-by: Christopher Larson Signed-off-by: Richard Purdie --- lib/bb/ui/ncurses.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/bb/ui/ncurses.py') diff --git a/lib/bb/ui/ncurses.py b/lib/bb/ui/ncurses.py index f6ea7f9bca..98647fc3e0 100644 --- a/lib/bb/ui/ncurses.py +++ b/lib/bb/ui/ncurses.py @@ -236,15 +236,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: @@ -345,10 +348,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 1.2.3-korg