summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/depexp.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/depexp.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/depexp.py')
-rw-r--r--bitbake/lib/bb/ui/depexp.py38
1 files changed, 25 insertions, 13 deletions
diff --git a/bitbake/lib/bb/ui/depexp.py b/bitbake/lib/bb/ui/depexp.py
index 1a716a88bf..85910f6925 100644
--- a/bitbake/lib/bb/ui/depexp.py
+++ b/bitbake/lib/bb/ui/depexp.py
@@ -198,17 +198,23 @@ class gtkthread(threading.Thread):
198 198
199def main(server, eventHandler): 199def main(server, eventHandler):
200 try: 200 try:
201 cmdline = server.runCommand(["getCmdLineAction"]) 201 cmdline, error = server.runCommand(["getCmdLineAction"])
202 if cmdline and not cmdline['action']: 202 if error:
203 print(cmdline['msg']) 203 print("Error getting bitbake commandline: %s" % error)
204 return 204 return 1
205 elif not cmdline or (cmdline['action'] and cmdline['action'][0] != "generateDotGraph"): 205 elif not cmdline:
206 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
207 return 1
208 elif not cmdline or cmdline[0] != "generateDotGraph":
206 print("This UI is only compatible with the -g option") 209 print("This UI is only compatible with the -g option")
207 return 210 return 1
208 ret = server.runCommand(["generateDepTreeEvent", cmdline['action'][1], cmdline['action'][2]]) 211 ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]])
209 if ret != True: 212 if error:
210 print("Couldn't run command! %s" % ret) 213 print("Error running command '%s': %s" % (cmdline, error))
211 return 214 return 1
215 elif ret != True:
216 print("Error running command '%s': returned %s" % (cmdline, ret))
217 return 1
212 except xmlrpclib.Fault as x: 218 except xmlrpclib.Fault as x:
213 print("XMLRPC Fault getting commandline:\n %s" % x) 219 print("XMLRPC Fault getting commandline:\n %s" % x)
214 return 220 return
@@ -234,7 +240,9 @@ def main(server, eventHandler):
234 try: 240 try:
235 event = eventHandler.waitEvent(0.25) 241 event = eventHandler.waitEvent(0.25)
236 if gtkthread.quit.isSet(): 242 if gtkthread.quit.isSet():
237 server.runCommand(["stateStop"]) 243 _, error = server.runCommand(["stateStop"])
244 if error:
245 print('Unable to cleanly stop: %s' % error)
238 break 246 break
239 247
240 if event is None: 248 if event is None:
@@ -310,9 +318,13 @@ def main(server, eventHandler):
310 break 318 break
311 if shutdown == 1: 319 if shutdown == 1:
312 print("\nSecond Keyboard Interrupt, stopping...\n") 320 print("\nSecond Keyboard Interrupt, stopping...\n")
313 server.runCommand(["stateStop"]) 321 _, error = server.runCommand(["stateStop"])
322 if error:
323 print('Unable to cleanly stop: %s' % error)
314 if shutdown == 0: 324 if shutdown == 0:
315 print("\nKeyboard Interrupt, closing down...\n") 325 print("\nKeyboard Interrupt, closing down...\n")
316 server.runCommand(["stateShutdown"]) 326 _, error = server.runCommand(["stateShutdown"])
327 if error:
328 print('Unable to cleanly shutdown: %s' % error)
317 shutdown = shutdown + 1 329 shutdown = shutdown + 1
318 pass 330 pass