From f3acb135e723258bd4b6072d5737d52e13d47054 Mon Sep 17 00:00:00 2001 From: Christopher Larson Date: Sun, 27 Jan 2013 15:41:20 -0800 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/crumbs/hobeventhandler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/bb/ui/crumbs/hobeventhandler.py') diff --git a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py index 52acec1028..21bea236c4 100644 --- a/bitbake/lib/bb/ui/crumbs/hobeventhandler.py +++ b/bitbake/lib/bb/ui/crumbs/hobeventhandler.py @@ -102,7 +102,10 @@ class HobHandler(gobject.GObject): def runCommand(self, commandline): try: - return self.server.runCommand(commandline) + result, error = self.server.runCommand(commandline) + if error: + raise Exception("Error running command '%s': %s" % (commandline, error)) + return result except Exception as e: self.commands_async = [] self.clear_busy() -- cgit v1.2.3-54-g00ecf