summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb
diff options
context:
space:
mode:
authorRob Bradford <rob@linux.intel.com>2008-10-23 14:28:11 +0100
committerRob Bradford <rob@linux.intel.com>2008-10-23 14:28:11 +0100
commitc26d6cfda09cb78aead92a9f868d0730ad1ad181 (patch)
tree2a71091711cf5f2b238d852307aeb63a41c979f9 /bitbake-dev/lib/bb
parentf0b1d561c7396f005a8308f32df24855181647fd (diff)
downloadpoky-c26d6cfda09cb78aead92a9f868d0730ad1ad181.tar.gz
bitbake-dev: Change terminology online/offline to sync/async
Change the terminology from online/offline to sync/async when referring to commands that return a result immediately versus those that produce changes that are emitted as events over time.
Diffstat (limited to 'bitbake-dev/lib/bb')
-rw-r--r--bitbake-dev/lib/bb/command.py76
-rw-r--r--bitbake-dev/lib/bb/cooker.py8
2 files changed, 42 insertions, 42 deletions
diff --git a/bitbake-dev/lib/bb/command.py b/bitbake-dev/lib/bb/command.py
index 8384e89e55..7cee1d5d36 100644
--- a/bitbake-dev/lib/bb/command.py
+++ b/bitbake-dev/lib/bb/command.py
@@ -21,79 +21,79 @@ Provide an interface to interact with the bitbake server through 'commands'
21 21
22""" 22"""
23The bitbake server takes 'commands' from its UI/commandline. 23The bitbake server takes 'commands' from its UI/commandline.
24Commands are either 'online' of 'offline' in nature. 24Commands are either synchronous or asynchronous.
25Offline commands return data to the client in the form of events. 25Async commands return data to the client in the form of events.
26Online commands must only return data through the function return value 26Sync commands must only return data through the function return value
27and must not trigger events, directly or indirectly. 27and must not trigger events, directly or indirectly.
28Commands are queued in a CommandQueue 28Commands are queued in a CommandQueue
29""" 29"""
30 30
31import bb 31import bb
32 32
33offline_cmds = {} 33async_cmds = {}
34online_cmds = {} 34sync_cmds = {}
35 35
36class Command: 36class Command:
37 """ 37 """
38 A queue of 'offline' commands for bitbake 38 A queue of asynchronous commands for bitbake
39 """ 39 """
40 def __init__(self, cooker): 40 def __init__(self, cooker):
41 41
42 self.cooker = cooker 42 self.cooker = cooker
43 self.cmds_online = CommandsOnline() 43 self.cmds_sync = CommandsSync()
44 self.cmds_offline = CommandsOffline() 44 self.cmds_async = CommandsAsync()
45 45
46 # FIXME Add lock for this 46 # FIXME Add lock for this
47 self.currentOfflineCommand = None 47 self.currentAsyncCommand = None
48 48
49 for attr in CommandsOnline.__dict__: 49 for attr in CommandsSync.__dict__:
50 command = attr[:].lower() 50 command = attr[:].lower()
51 method = getattr(CommandsOnline, attr) 51 method = getattr(CommandsSync, attr)
52 online_cmds[command] = (method) 52 sync_cmds[command] = (method)
53 53
54 for attr in CommandsOffline.__dict__: 54 for attr in CommandsAsync.__dict__:
55 command = attr[:].lower() 55 command = attr[:].lower()
56 method = getattr(CommandsOffline, attr) 56 method = getattr(CommandsAsync, attr)
57 offline_cmds[command] = (method) 57 async_cmds[command] = (method)
58 58
59 def runCommand(self, commandline): 59 def runCommand(self, commandline):
60 try: 60 try:
61 command = commandline.pop(0) 61 command = commandline.pop(0)
62 if command in CommandsOnline.__dict__: 62 if command in CommandsSync.__dict__:
63 # Can run online commands straight away 63 # Can run online commands straight away
64 return getattr(CommandsOnline, command)(self.cmds_online, self, commandline) 64 return getattr(CommandsSync, command)(self.cmds_sync, self, commandline)
65 if self.currentOfflineCommand is not None: 65 if self.currentAsyncCommand is not None:
66 return "Busy (%s in progress)" % self.currentOfflineCommand[0] 66 return "Busy (%s in progress)" % self.currentAsyncCommand[0]
67 if command not in CommandsOffline.__dict__: 67 if command not in CommandsAsync.__dict__:
68 return "No such command" 68 return "No such command"
69 self.currentOfflineCommand = (command, commandline) 69 self.currentAsyncCommand = (command, commandline)
70 return True 70 return True
71 except: 71 except:
72 import traceback 72 import traceback
73 return traceback.format_exc() 73 return traceback.format_exc()
74 74
75 def runOfflineCommand(self): 75 def runAsyncCommand(self):
76 try: 76 try:
77 if self.currentOfflineCommand is not None: 77 if self.currentAsyncCommand is not None:
78 (command, options) = self.currentOfflineCommand 78 (command, options) = self.currentAsyncCommand
79 getattr(CommandsOffline, command)(self.cmds_offline, self, options) 79 getattr(CommandsAsync, command)(self.cmds_async, self, options)
80 except: 80 except:
81 import traceback 81 import traceback
82 self.finishOfflineCommand(traceback.format_exc()) 82 self.finishAsyncCommand(traceback.format_exc())
83 83
84 def finishOfflineCommand(self, error = None): 84 def finishAsyncCommand(self, error = None):
85 if error: 85 if error:
86 bb.event.fire(bb.command.CookerCommandFailed(self.cooker.configuration.event_data, error)) 86 bb.event.fire(bb.command.CookerCommandFailed(self.cooker.configuration.event_data, error))
87 else: 87 else:
88 bb.event.fire(bb.command.CookerCommandCompleted(self.cooker.configuration.event_data)) 88 bb.event.fire(bb.command.CookerCommandCompleted(self.cooker.configuration.event_data))
89 self.currentOfflineCommand = None 89 self.currentAsyncCommand = None
90 90
91 91
92class CommandsOnline: 92class CommandsSync:
93 """ 93 """
94 A class of online commands 94 A class of synchronous commands
95 These should run quickly so as not to hurt interactive performance. 95 These should run quickly so as not to hurt interactive performance.
96 These must not influence any running offline command. 96 These must not influence any running synchronous command.
97 """ 97 """
98 98
99 def stateShutdown(self, command, params): 99 def stateShutdown(self, command, params):
@@ -125,9 +125,9 @@ class CommandsOnline:
125 125
126 return bb.data.getVar(varname, command.cooker.configuration.data, expand) 126 return bb.data.getVar(varname, command.cooker.configuration.data, expand)
127 127
128class CommandsOffline: 128class CommandsAsync:
129 """ 129 """
130 A class of offline commands 130 A class of asynchronous commands
131 These functions communicate via generated events. 131 These functions communicate via generated events.
132 Any function that requires metadata parsing should be here. 132 Any function that requires metadata parsing should be here.
133 """ 133 """
@@ -156,7 +156,7 @@ class CommandsOffline:
156 pkgs_to_build = params[0] 156 pkgs_to_build = params[0]
157 157
158 command.cooker.generateDepTreeEvent(pkgs_to_build) 158 command.cooker.generateDepTreeEvent(pkgs_to_build)
159 command.finishOfflineCommand() 159 command.finishAsyncCommand()
160 160
161 def generateDotGraph(self, command, params): 161 def generateDotGraph(self, command, params):
162 """ 162 """
@@ -165,14 +165,14 @@ class CommandsOffline:
165 pkgs_to_build = params[0] 165 pkgs_to_build = params[0]
166 166
167 command.cooker.generateDotGraphFiles(pkgs_to_build) 167 command.cooker.generateDotGraphFiles(pkgs_to_build)
168 command.finishOfflineCommand() 168 command.finishAsyncCommand()
169 169
170 def showVersions(self, command, params): 170 def showVersions(self, command, params):
171 """ 171 """
172 Show the currently selected versions 172 Show the currently selected versions
173 """ 173 """
174 command.cooker.showVersions() 174 command.cooker.showVersions()
175 command.finishOfflineCommand() 175 command.finishAsyncCommand()
176 176
177 def showEnvironment(self, command, params): 177 def showEnvironment(self, command, params):
178 """ 178 """
@@ -182,14 +182,14 @@ class CommandsOffline:
182 pkg = params[1] 182 pkg = params[1]
183 183
184 command.cooker.showEnvironment(bfile, pkg) 184 command.cooker.showEnvironment(bfile, pkg)
185 command.finishOfflineCommand() 185 command.finishAsyncCommand()
186 186
187 def parseFiles(self, command, params): 187 def parseFiles(self, command, params):
188 """ 188 """
189 Parse the .bb files 189 Parse the .bb files
190 """ 190 """
191 command.cooker.updateCache() 191 command.cooker.updateCache()
192 command.finishOfflineCommand() 192 command.finishAsyncCommand()
193 193
194# 194#
195# Events 195# Events
diff --git a/bitbake-dev/lib/bb/cooker.py b/bitbake-dev/lib/bb/cooker.py
index e3bb56d376..339bb45ec1 100644
--- a/bitbake-dev/lib/bb/cooker.py
+++ b/bitbake-dev/lib/bb/cooker.py
@@ -169,12 +169,12 @@ class BBCooker:
169 169
170 def runCommands(self, server, data, abort): 170 def runCommands(self, server, data, abort):
171 """ 171 """
172 Run any queued offline command 172 Run any queued asynchronous command
173 This is done by the idle handler so it runs in true context rather than 173 This is done by the idle handler so it runs in true context rather than
174 tied to any UI. 174 tied to any UI.
175 """ 175 """
176 if self.cookerIdle and not abort: 176 if self.cookerIdle and not abort:
177 self.command.runOfflineCommand() 177 self.command.runAsyncCommand()
178 178
179 # Always reschedule 179 # Always reschedule
180 return True 180 return True
@@ -670,7 +670,7 @@ class BBCooker:
670 retval = False 670 retval = False
671 if not retval: 671 if not retval:
672 self.cookerIdle = True 672 self.cookerIdle = True
673 self.command.finishOfflineCommand() 673 self.command.finishAsyncCommand()
674 bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures)) 674 bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
675 return retval 675 return retval
676 676
@@ -703,7 +703,7 @@ class BBCooker:
703 retval = False 703 retval = False
704 if not retval: 704 if not retval:
705 self.cookerIdle = True 705 self.cookerIdle = True
706 self.command.finishOfflineCommand() 706 self.command.finishAsyncCommand()
707 bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures)) 707 bb.event.fire(bb.event.BuildCompleted(buildname, targets, self.configuration.event_data, failures))
708 return retval 708 return retval
709 709