summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/ncurses.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/ncurses.py
parent99fa251b5696dff77358d514175bbb08802a7a02 (diff)
downloadpoky-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/ncurses.py')
-rw-r--r--bitbake/lib/bb/ui/ncurses.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py
index f6ea7f9bca..98647fc3e0 100644
--- a/bitbake/lib/bb/ui/ncurses.py
+++ b/bitbake/lib/bb/ui/ncurses.py
@@ -236,15 +236,18 @@ class NCursesUI:
236 shutdown = 0 236 shutdown = 0
237 237
238 try: 238 try:
239 cmdline = server.runCommand(["getCmdLineAction"]) 239 cmdline, error = server.runCommand(["getCmdLineAction"])
240 if not cmdline: 240 if not cmdline:
241 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 241 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
242 return 242 return
243 elif not cmdline['action']: 243 elif error:
244 print(cmdline['msg']) 244 print("Error getting bitbake commandline: %s" % error)
245 return 245 return
246 ret = server.runCommand(cmdline['action']) 246 ret, error = server.runCommand(cmdline)
247 if ret != True: 247 if error:
248 print("Error running command '%s': %s" % (cmdline, error))
249 return
250 elif ret != True:
248 print("Couldn't get default commandlind! %s" % ret) 251 print("Couldn't get default commandlind! %s" % ret)
249 return 252 return
250 except xmlrpclib.Fault as x: 253 except xmlrpclib.Fault as x:
@@ -345,10 +348,14 @@ class NCursesUI:
345 exitflag = True 348 exitflag = True
346 if shutdown == 1: 349 if shutdown == 1:
347 mw.appendText("Second Keyboard Interrupt, stopping...\n") 350 mw.appendText("Second Keyboard Interrupt, stopping...\n")
348 server.runCommand(["stateStop"]) 351 _, error = server.runCommand(["stateStop"])
352 if error:
353 print("Unable to cleanly stop: %s" % error)
349 if shutdown == 0: 354 if shutdown == 0:
350 mw.appendText("Keyboard Interrupt, closing down...\n") 355 mw.appendText("Keyboard Interrupt, closing down...\n")
351 server.runCommand(["stateShutdown"]) 356 _, error = server.runCommand(["stateShutdown"])
357 if error:
358 print("Unable to cleanly shutdown: %s" % error)
352 shutdown = shutdown + 1 359 shutdown = shutdown + 1
353 pass 360 pass
354 361