summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui/knotty.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/knotty.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/knotty.py')
-rw-r--r--bitbake/lib/bb/ui/knotty.py45
1 files changed, 31 insertions, 14 deletions
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 01674169ec..439a792800 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -107,9 +107,18 @@ class TerminalFilter(object):
107def main(server, eventHandler, tf = TerminalFilter): 107def main(server, eventHandler, tf = TerminalFilter):
108 108
109 # Get values of variables which control our output 109 # Get values of variables which control our output
110 includelogs = server.runCommand(["getVariable", "BBINCLUDELOGS"]) 110 includelogs, error = server.runCommand(["getVariable", "BBINCLUDELOGS"])
111 loglines = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"]) 111 if error:
112 consolelogfile = server.runCommand(["getVariable", "BB_CONSOLELOG"]) 112 logger.error("Unable to get the value of BBINCLUDELOGS variable: %s" % error)
113 return 1
114 loglines, error = server.runCommand(["getVariable", "BBINCLUDELOGS_LINES"])
115 if error:
116 logger.error("Unable to get the value of BBINCLUDELOGS_LINES variable: %s" % error)
117 return 1
118 consolelogfile, error = server.runCommand(["getVariable", "BB_CONSOLELOG"])
119 if error:
120 logger.error("Unable to get the value of BB_CONSOLELOG variable: %s" % error)
121 return 1
113 122
114 helper = uihelper.BBUIHelper() 123 helper = uihelper.BBUIHelper()
115 124
@@ -125,19 +134,22 @@ def main(server, eventHandler, tf = TerminalFilter):
125 logger.addHandler(consolelog) 134 logger.addHandler(consolelog)
126 135
127 try: 136 try:
128 cmdline = server.runCommand(["getCmdLineAction"]) 137 cmdline, error = server.runCommand(["getCmdLineAction"])
129 if not cmdline: 138 if error:
139 logger.error("Unable to get bitbake commandline arguments: %s" % error)
140 return 1
141 elif not cmdline:
130 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") 142 print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.")
131 return 1 143 return 1
132 elif not cmdline['action']: 144 ret, error = server.runCommand(cmdline)
133 print(cmdline['msg']) 145 if error:
146 logger.error("Command '%s' failed: %s" % (cmdline, error))
134 return 1 147 return 1
135 ret = server.runCommand(cmdline['action']) 148 elif ret != True:
136 if ret != True: 149 logger.error("Command '%s' failed: returned %s" % (cmdline, ret))
137 print("Couldn't get default commandline! %s" % ret)
138 return 1 150 return 1
139 except xmlrpclib.Fault as x: 151 except xmlrpclib.Fault as x:
140 print("XMLRPC Fault getting commandline:\n %s" % x) 152 logger.error("XMLRPC Fault getting commandline:\n %s" % x)
141 return 1 153 return 1
142 154
143 parseprogress = None 155 parseprogress = None
@@ -318,14 +330,19 @@ def main(server, eventHandler, tf = TerminalFilter):
318 if ioerror.args[0] == 4: 330 if ioerror.args[0] == 4:
319 pass 331 pass
320 except KeyboardInterrupt: 332 except KeyboardInterrupt:
333 import time
321 termfilter.clearFooter() 334 termfilter.clearFooter()
322 if main.shutdown == 1: 335 if main.shutdown == 1:
323 print("\nSecond Keyboard Interrupt, stopping...\n") 336 print("\nSecond Keyboard Interrupt, stopping...\n")
324 server.runCommand(["stateStop"]) 337 _, error = server.runCommand(["stateStop"])
338 if error:
339 logger.error("Unable to cleanly stop: %s" % error)
325 if main.shutdown == 0: 340 if main.shutdown == 0:
326 interrupted = True
327 print("\nKeyboard Interrupt, closing down...\n") 341 print("\nKeyboard Interrupt, closing down...\n")
328 server.runCommand(["stateShutdown"]) 342 interrupted = True
343 _, error = server.runCommand(["stateShutdown"])
344 if error:
345 logger.error("Unable to cleanly shutdown: %s" % error)
329 main.shutdown = main.shutdown + 1 346 main.shutdown = main.shutdown + 1
330 pass 347 pass
331 348