summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/command.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/command.py')
-rw-r--r--bitbake/lib/bb/command.py43
1 files changed, 27 insertions, 16 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 27b5171a6e..3f28bca257 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -44,6 +44,9 @@ class CommandFailed(CommandExit):
44 self.error = message 44 self.error = message
45 CommandExit.__init__(self, 1) 45 CommandExit.__init__(self, 1)
46 46
47class CommandError(Exception):
48 pass
49
47class Command: 50class Command:
48 """ 51 """
49 A queue of asynchronous commands for bitbake 52 A queue of asynchronous commands for bitbake
@@ -57,21 +60,25 @@ class Command:
57 self.currentAsyncCommand = None 60 self.currentAsyncCommand = None
58 61
59 def runCommand(self, commandline): 62 def runCommand(self, commandline):
60 try: 63 command = commandline.pop(0)
61 command = commandline.pop(0) 64 if hasattr(CommandsSync, command):
62 if command in CommandsSync.__dict__: 65 # Can run synchronous commands straight away
63 # Can run synchronous commands straight away 66 command_method = getattr(self.cmds_sync, command)
64 return getattr(CommandsSync, command)(self.cmds_sync, self, commandline) 67 try:
65 if self.currentAsyncCommand is not None: 68 result = command_method(self, commandline)
66 return "Busy (%s in progress)" % self.currentAsyncCommand[0] 69 except CommandError as exc:
67 if command not in CommandsAsync.__dict__: 70 return None, exc.args[0]
68 return "No such command" 71 except Exception:
69 self.currentAsyncCommand = (command, commandline) 72 return None, traceback.format_exc()
70 self.cooker.server_registration_cb(self.cooker.runCommands, self.cooker) 73 else:
71 return True 74 return result, None
72 except: 75 if self.currentAsyncCommand is not None:
73 import traceback 76 return None, "Busy (%s in progress)" % self.currentAsyncCommand[0]
74 return traceback.format_exc() 77 if command not in CommandsAsync.__dict__:
78 return None, "No such command"
79 self.currentAsyncCommand = (command, commandline)
80 self.cooker.server_registration_cb(self.cooker.runCommands, self.cooker)
81 return True, None
75 82
76 def runAsyncCommand(self): 83 def runAsyncCommand(self):
77 try: 84 try:
@@ -139,7 +146,11 @@ class CommandsSync:
139 """ 146 """
140 Get any command parsed from the commandline 147 Get any command parsed from the commandline
141 """ 148 """
142 return command.cooker.commandlineAction 149 cmd_action = command.cooker.commandlineAction
150 if cmd_action['msg']:
151 raise CommandError(msg)
152 else:
153 return cmd_action['action']
143 154
144 def getVariable(self, command, params): 155 def getVariable(self, command, params):
145 """ 156 """