diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/command.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 11 | ||||
-rw-r--r-- | bitbake/lib/bb/server/none.py | 59 | ||||
-rw-r--r-- | bitbake/lib/bb/server/xmlrpc.py | 50 |
4 files changed, 78 insertions, 44 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index e83751a2fa..9841e6874e 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py | |||
@@ -82,7 +82,7 @@ class Command: | |||
82 | if command not in CommandsAsync.__dict__: | 82 | if command not in CommandsAsync.__dict__: |
83 | return "No such command" | 83 | return "No such command" |
84 | self.currentAsyncCommand = (command, commandline) | 84 | self.currentAsyncCommand = (command, commandline) |
85 | self.cooker.server.register_idle_function(self.cooker.runCommands, self.cooker) | 85 | self.cooker.server_registration_cb(self.cooker.runCommands, self.cooker) |
86 | return True | 86 | return True |
87 | except: | 87 | except: |
88 | import traceback | 88 | import traceback |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 8379d0caf1..94495e1399 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -63,12 +63,11 @@ class BBCooker: | |||
63 | Manages one bitbake build run | 63 | Manages one bitbake build run |
64 | """ | 64 | """ |
65 | 65 | ||
66 | def __init__(self, configuration, server): | 66 | def __init__(self, configuration, server_registration_cb): |
67 | self.status = None | 67 | self.status = None |
68 | self.appendlist = {} | 68 | self.appendlist = {} |
69 | 69 | ||
70 | if server: | 70 | self.server_registration_cb = server_registration_cb |
71 | self.server = server.BitBakeServer(self) | ||
72 | 71 | ||
73 | self.configuration = configuration | 72 | self.configuration = configuration |
74 | 73 | ||
@@ -109,7 +108,7 @@ class BBCooker: | |||
109 | 108 | ||
110 | self.configuration.data = bb.data.init() | 109 | self.configuration.data = bb.data.init() |
111 | 110 | ||
112 | if not server: | 111 | if not self.server_registration_cb: |
113 | bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data) | 112 | bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data) |
114 | 113 | ||
115 | bb.data.inheritFromOS(self.configuration.data) | 114 | bb.data.inheritFromOS(self.configuration.data) |
@@ -831,7 +830,7 @@ class BBCooker: | |||
831 | return True | 830 | return True |
832 | return retval | 831 | return retval |
833 | 832 | ||
834 | self.server.register_idle_function(buildFileIdle, rq) | 833 | self.server_registration_cb(buildFileIdle, rq) |
835 | 834 | ||
836 | def buildTargets(self, targets, task): | 835 | def buildTargets(self, targets, task): |
837 | """ | 836 | """ |
@@ -890,7 +889,7 @@ class BBCooker: | |||
890 | 889 | ||
891 | rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) | 890 | rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) |
892 | 891 | ||
893 | self.server.register_idle_function(buildTargetsIdle, rq) | 892 | self.server_registration_cb(buildTargetsIdle, rq) |
894 | 893 | ||
895 | def updateCache(self): | 894 | def updateCache(self): |
896 | if self.state == state.running: | 895 | if self.state == state.running: |
diff --git a/bitbake/lib/bb/server/none.py b/bitbake/lib/bb/server/none.py index 45cda2f5f4..6083631fe7 100644 --- a/bitbake/lib/bb/server/none.py +++ b/bitbake/lib/bb/server/none.py | |||
@@ -36,8 +36,7 @@ DEBUG = False | |||
36 | import inspect, select | 36 | import inspect, select |
37 | 37 | ||
38 | class BitBakeServerCommands(): | 38 | class BitBakeServerCommands(): |
39 | def __init__(self, server, cooker): | 39 | def __init__(self, server): |
40 | self.cooker = cooker | ||
41 | self.server = server | 40 | self.server = server |
42 | 41 | ||
43 | def runCommand(self, command): | 42 | def runCommand(self, command): |
@@ -106,13 +105,17 @@ class BBUIEventQueue: | |||
106 | def chldhandler(signum, stackframe): | 105 | def chldhandler(signum, stackframe): |
107 | pass | 106 | pass |
108 | 107 | ||
109 | class BitBakeServer(): | 108 | class BitBakeNoneServer(): |
110 | # remove this when you're done with debugging | 109 | # remove this when you're done with debugging |
111 | # allow_reuse_address = True | 110 | # allow_reuse_address = True |
112 | 111 | ||
113 | def __init__(self, cooker): | 112 | def __init__(self): |
114 | self._idlefuns = {} | 113 | self._idlefuns = {} |
115 | self.commands = BitBakeServerCommands(self, cooker) | 114 | self.commands = BitBakeServerCommands(self) |
115 | |||
116 | def addcooker(self, cooker): | ||
117 | self.cooker = cooker | ||
118 | self.commands.cooker = cooker | ||
116 | 119 | ||
117 | def register_idle_function(self, function, data): | 120 | def register_idle_function(self, function, data): |
118 | """Register a function to be called while the server is idle""" | 121 | """Register a function to be called while the server is idle""" |
@@ -157,25 +160,10 @@ class BitBakeServer(): | |||
157 | except: | 160 | except: |
158 | pass | 161 | pass |
159 | 162 | ||
160 | class BitbakeServerInfo(): | ||
161 | def __init__(self, server): | ||
162 | self.server = server | ||
163 | self.commands = server.commands | ||
164 | |||
165 | class BitBakeServerFork(): | ||
166 | def __init__(self, cooker, server, serverinfo, logfile): | ||
167 | serverinfo.logfile = logfile | ||
168 | serverinfo.cooker = cooker | ||
169 | serverinfo.server = server | ||
170 | |||
171 | class BitbakeUILauch(): | ||
172 | def launch(self, serverinfo, uifunc, *args): | ||
173 | return bb.cooker.server_main(serverinfo.cooker, uifunc, *args) | ||
174 | |||
175 | class BitBakeServerConnection(): | 163 | class BitBakeServerConnection(): |
176 | def __init__(self, serverinfo): | 164 | def __init__(self, server): |
177 | self.server = serverinfo.server | 165 | self.server = server.server |
178 | self.connection = serverinfo.commands | 166 | self.connection = self.server.commands |
179 | self.events = bb.server.none.BBUIEventQueue(self.server) | 167 | self.events = bb.server.none.BBUIEventQueue(self.server) |
180 | for event in bb.event.ui_queue: | 168 | for event in bb.event.ui_queue: |
181 | self.events.queue_event(event) | 169 | self.events.queue_event(event) |
@@ -189,3 +177,28 @@ class BitBakeServerConnection(): | |||
189 | self.connection.terminateServer() | 177 | self.connection.terminateServer() |
190 | except: | 178 | except: |
191 | pass | 179 | pass |
180 | |||
181 | class BitBakeServer(object): | ||
182 | def initServer(self): | ||
183 | self.server = BitBakeNoneServer() | ||
184 | |||
185 | def addcooker(self, cooker): | ||
186 | self.cooker = cooker | ||
187 | self.server.addcooker(cooker) | ||
188 | |||
189 | def getServerIdleCB(self): | ||
190 | return self.server.register_idle_function | ||
191 | |||
192 | def saveConnectionDetails(self): | ||
193 | return | ||
194 | |||
195 | def detach(self, cooker_logfile): | ||
196 | self.logfile = cooker_logfile | ||
197 | |||
198 | def establishConnection(self): | ||
199 | self.connection = BitBakeServerConnection(self) | ||
200 | return self.connection | ||
201 | |||
202 | def launchUI(self, uifunc, *args): | ||
203 | return bb.cooker.server_main(self.cooker, uifunc, *args) | ||
204 | |||
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py index e7b6010874..4a16f9d525 100644 --- a/bitbake/lib/bb/server/xmlrpc.py +++ b/bitbake/lib/bb/server/xmlrpc.py | |||
@@ -122,8 +122,7 @@ def _create_server(host, port): | |||
122 | return s | 122 | return s |
123 | 123 | ||
124 | class BitBakeServerCommands(): | 124 | class BitBakeServerCommands(): |
125 | def __init__(self, server, cooker): | 125 | def __init__(self, server): |
126 | self.cooker = cooker | ||
127 | self.server = server | 126 | self.server = server |
128 | 127 | ||
129 | def registerEventHandler(self, host, port): | 128 | def registerEventHandler(self, host, port): |
@@ -160,11 +159,11 @@ class BitBakeServerCommands(): | |||
160 | """ | 159 | """ |
161 | return True | 160 | return True |
162 | 161 | ||
163 | class BitBakeServer(SimpleXMLRPCServer): | 162 | class BitBakeXMLRPCServer(SimpleXMLRPCServer): |
164 | # remove this when you're done with debugging | 163 | # remove this when you're done with debugging |
165 | # allow_reuse_address = True | 164 | # allow_reuse_address = True |
166 | 165 | ||
167 | def __init__(self, cooker, interface = ("localhost", 0)): | 166 | def __init__(self, interface = ("localhost", 0)): |
168 | """ | 167 | """ |
169 | Constructor | 168 | Constructor |
170 | """ | 169 | """ |
@@ -174,9 +173,12 @@ class BitBakeServer(SimpleXMLRPCServer): | |||
174 | self._idlefuns = {} | 173 | self._idlefuns = {} |
175 | self.host, self.port = self.socket.getsockname() | 174 | self.host, self.port = self.socket.getsockname() |
176 | #self.register_introspection_functions() | 175 | #self.register_introspection_functions() |
177 | commands = BitBakeServerCommands(self, cooker) | 176 | self.commands = BitBakeServerCommands(self) |
178 | self.autoregister_all_functions(commands, "") | 177 | self.autoregister_all_functions(self.commands, "") |
178 | |||
179 | def addcooker(self, cooker): | ||
179 | self.cooker = cooker | 180 | self.cooker = cooker |
181 | self.commands.cooker = cooker | ||
180 | 182 | ||
181 | def autoregister_all_functions(self, context, prefix): | 183 | def autoregister_all_functions(self, context, prefix): |
182 | """ | 184 | """ |
@@ -244,14 +246,6 @@ class BitbakeServerInfo(): | |||
244 | self.host = server.host | 246 | self.host = server.host |
245 | self.port = server.port | 247 | self.port = server.port |
246 | 248 | ||
247 | class BitBakeServerFork(): | ||
248 | def __init__(self, cooker, server, serverinfo, logfile): | ||
249 | daemonize.createDaemon(server.serve_forever, logfile) | ||
250 | |||
251 | class BitbakeUILauch(): | ||
252 | def launch(self, serverinfo, uifunc, *args): | ||
253 | return uifunc(*args) | ||
254 | |||
255 | class BitBakeServerConnection(): | 249 | class BitBakeServerConnection(): |
256 | def __init__(self, serverinfo): | 250 | def __init__(self, serverinfo): |
257 | self.connection = _create_server(serverinfo.host, serverinfo.port) | 251 | self.connection = _create_server(serverinfo.host, serverinfo.port) |
@@ -271,3 +265,31 @@ class BitBakeServerConnection(): | |||
271 | self.connection.terminateServer() | 265 | self.connection.terminateServer() |
272 | except: | 266 | except: |
273 | pass | 267 | pass |
268 | |||
269 | class BitBakeServer(object): | ||
270 | def initServer(self): | ||
271 | self.server = BitBakeXMLRPCServer() | ||
272 | |||
273 | def addcooker(self, cooker): | ||
274 | self.cooker = cooker | ||
275 | self.server.addcooker(cooker) | ||
276 | |||
277 | def getServerIdleCB(self): | ||
278 | return self.server.register_idle_function | ||
279 | |||
280 | def saveConnectionDetails(self): | ||
281 | self.serverinfo = BitbakeServerInfo(self.server) | ||
282 | |||
283 | def detach(self, cooker_logfile): | ||
284 | daemonize.createDaemon(self.server.serve_forever, cooker_logfile) | ||
285 | del self.cooker | ||
286 | del self.server | ||
287 | |||
288 | def establishConnection(self): | ||
289 | self.connection = BitBakeServerConnection(self.serverinfo) | ||
290 | return self.connection | ||
291 | |||
292 | def launchUI(self, uifunc, *args): | ||
293 | return uifunc(*args) | ||
294 | |||
295 | |||