From 69aab78dd830b0ad570cf9b7bfe2da8e8b793e23 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 23 Aug 2013 16:16:50 +0000 Subject: bitbake: bitbake: Add ui event handlers filtering Add functionality to allow UIs to update and change the types of events they recieve. To do this we need to add a new command and also need to be able to obtain the current event hander ID. In the case of xmlrpc, this is straightforward, in the case of the process server we need to save the result in a multiprocessing.Value() so we can retrive it. An excplit command was added to the server API to facilitate this. The same function can also be used to mask or unmask specific log messages, allowing the UI to optionally differ from the standard set of message filtering. Based upon work by Cristiana Voicu (Bitbake rev: ba5a6c88785d9889d4172ec79937ac2a5555327e) Signed-off-by: Richard Purdie --- bitbake/lib/bb/server/process.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'bitbake/lib/bb/server/process.py') diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py index 99a6bf55cc..e2cec49b74 100644 --- a/bitbake/lib/bb/server/process.py +++ b/bitbake/lib/bb/server/process.py @@ -37,8 +37,9 @@ from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer logger = logging.getLogger('BitBake') class ServerCommunicator(): - def __init__(self, connection): + def __init__(self, connection, event_handle): self.connection = connection + self.event_handle = event_handle def runCommand(self, command): # @todo try/except @@ -54,6 +55,8 @@ class ServerCommunicator(): except KeyboardInterrupt: pass + def getEventHandle(self): + return self.event_handle.value class EventAdapter(): """ @@ -84,11 +87,12 @@ class ProcessServer(Process, BaseImplServer): self.keep_running = Event() self.keep_running.set() + self.event_handle = multiprocessing.Value("i") def run(self): for event in bb.event.ui_queue: self.event_queue.put(event) - self.event_handle = bb.event.register_UIHhandler(self) + self.event_handle.value = bb.event.register_UIHhandler(self) bb.cooker.server_main(self.cooker, self.main) def main(self): @@ -106,7 +110,7 @@ class ProcessServer(Process, BaseImplServer): logger.exception('Running command %s', command) self.event_queue.close() - bb.event.unregister_UIHhandler(self.event_handle) + bb.event.unregister_UIHhandler(self.event_handle.value) self.command_channel.close() self.cooker.stop() self.idle_commands(.1) @@ -147,7 +151,7 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection): self.procserver = serverImpl self.ui_channel = ui_channel self.event_queue = event_queue - self.connection = ServerCommunicator(self.ui_channel) + self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle) self.events = self.event_queue def terminate(self): -- cgit v1.2.3-54-g00ecf