summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/depexp.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/depexp.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/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 b62adbf851..1254128edd 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
@@ -229,7 +235,9 @@ def main(server, eventHandler):
229 try: 235 try:
230 event = eventHandler.waitEvent(0.25) 236 event = eventHandler.waitEvent(0.25)
231 if gtkthread.quit.isSet(): 237 if gtkthread.quit.isSet():
232 server.runCommand(["stateStop"]) 238 _, error = server.runCommand(["stateStop"])
239 if error:
240 print('Unable to cleanly stop: %s' % error)
233 break 241 break
234 242
235 if event is None: 243 if event is None:
@@ -302,9 +310,13 @@ def main(server, eventHandler):
302 break 310 break
303 if shutdown == 1: 311 if shutdown == 1:
304 print("\nSecond Keyboard Interrupt, stopping...\n") 312 print("\nSecond Keyboard Interrupt, stopping...\n")
305 server.runCommand(["stateStop"]) 313 _, error = server.runCommand(["stateStop"])
314 if error:
315 print('Unable to cleanly stop: %s' % error)
306 if shutdown == 0: 316 if shutdown == 0:
307 print("\nKeyboard Interrupt, closing down...\n") 317 print("\nKeyboard Interrupt, closing down...\n")
308 server.runCommand(["stateShutdown"]) 318 _, error = server.runCommand(["stateShutdown"])
319 if error:
320 print('Unable to cleanly shutdown: %s' % error)
309 shutdown = shutdown + 1 321 shutdown = shutdown + 1
310 pass 322 pass