summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/ncurses.py
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2013-01-27 15:41:20 -0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-28 12:43:58 +0000
commitf3acb135e723258bd4b6072d5737d52e13d47054 (patch)
tree3ffa0492ceb3cce8c3094e21d239f048caedcc62 /bitbake/lib/bb/ui/ncurses.py
parent878ef6a31c2cea4b6a1012f5b5e29a3bc4d01119 (diff)
downloadpoky-f3acb135e723258bd4b6072d5737d52e13d47054.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 8524446d22..896ed01a78 100644
--- a/bitbake/lib/bb/ui/ncurses.py
+++ b/bitbake/lib/bb/ui/ncurses.py
@@ -230,15 +230,18 @@ class NCursesUI:
230 shutdown = 0 230 shutdown = 0
231 231
232 try: 232 try:
233 cmdline = server.runCommand(["getCmdLineAction"]) 233 cmdline, error = server.runCommand(["getCmdLineAction"])
234 if not cmdline: 234 if not cmdline:
235 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 235 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
236 return 236 return
237 elif not cmdline['action']: 237 elif error:
238 print(cmdline['msg']) 238 print("Error getting bitbake commandline: %s" % error)
239 return 239 return
240 ret = server.runCommand(cmdline['action']) 240 ret, error = server.runCommand(cmdline)
241 if ret != True: 241 if error:
242 print("Error running command '%s': %s" % (cmdline, error))
243 return
244 elif ret != True:
242 print("Couldn't get default commandlind! %s" % ret) 245 print("Couldn't get default commandlind! %s" % ret)
243 return 246 return
244 except xmlrpclib.Fault as x: 247 except xmlrpclib.Fault as x:
@@ -337,10 +340,14 @@ class NCursesUI:
337 exitflag = True 340 exitflag = True
338 if shutdown == 1: 341 if shutdown == 1:
339 mw.appendText("Second Keyboard Interrupt, stopping...\n") 342 mw.appendText("Second Keyboard Interrupt, stopping...\n")
340 server.runCommand(["stateStop"]) 343 _, error = server.runCommand(["stateStop"])
344 if error:
345 print("Unable to cleanly stop: %s" % error)
341 if shutdown == 0: 346 if shutdown == 0:
342 mw.appendText("Keyboard Interrupt, closing down...\n") 347 mw.appendText("Keyboard Interrupt, closing down...\n")
343 server.runCommand(["stateShutdown"]) 348 _, error = server.runCommand(["stateShutdown"])
349 if error:
350 print("Unable to cleanly shutdown: %s" % error)
344 shutdown = shutdown + 1 351 shutdown = shutdown + 1
345 pass 352 pass
346 353