summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-23 16:16:50 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-26 10:29:46 (GMT)
commit69aab78dd830b0ad570cf9b7bfe2da8e8b793e23 (patch)
tree8c799233df8ef5f3e9129da4c54241acea2c65f9 /bitbake
parentbfab986ccd59636d0b0e79309f020e55481b0567 (diff)
downloadpoky-69aab78dd830b0ad570cf9b7bfe2da8e8b793e23.tar.gz
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 <cristiana.voicu@intel.com> (Bitbake rev: ba5a6c88785d9889d4172ec79937ac2a5555327e) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/command.py7
-rw-r--r--bitbake/lib/bb/event.py17
-rw-r--r--bitbake/lib/bb/server/process.py12
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py6
-rw-r--r--bitbake/lib/bb/ui/knotty.py12
5 files changed, 46 insertions, 8 deletions
diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py
index 33a2440..bdf1c36 100644
--- a/bitbake/lib/bb/command.py
+++ b/bitbake/lib/bb/command.py
@@ -240,6 +240,13 @@ class CommandsSync:
240 name = params[0] 240 name = params[0]
241 command.cooker.createConfigFile(name) 241 command.cooker.createConfigFile(name)
242 242
243 def setEventMask(self, command, params):
244 handlerNum = params[0]
245 llevel = params[1]
246 debug_domains = params[2]
247 mask = params[3]
248 return bb.event.set_UIHmask(handlerNum, llevel, debug_domains, mask)
249
243class CommandsAsync: 250class CommandsAsync:
244 """ 251 """
245 A class of asynchronous commands 252 A class of asynchronous commands
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 8ffd2c3..1169cbf 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -193,7 +193,7 @@ def register(name, handler, mask=[]):
193 else: 193 else:
194 _handlers[name] = handler 194 _handlers[name] = handler
195 195
196 if not mask: 196 if not mask or '*' in mask:
197 _catchall_handlers[name] = True 197 _catchall_handlers[name] = True
198 else: 198 else:
199 for m in mask: 199 for m in mask:
@@ -225,7 +225,7 @@ class UIEventFilter(object):
225 self.update(None, level, debug_domains) 225 self.update(None, level, debug_domains)
226 226
227 def update(self, eventmask, level, debug_domains): 227 def update(self, eventmask, level, debug_domains):
228 self.eventmask = None 228 self.eventmask = eventmask
229 self.stdlevel = level 229 self.stdlevel = level
230 self.debug_domains = debug_domains 230 self.debug_domains = debug_domains
231 231
@@ -236,9 +236,20 @@ class UIEventFilter(object):
236 if event.name in self.debug_domains and event.levelno >= self.debug_domains[event.name]: 236 if event.name in self.debug_domains and event.levelno >= self.debug_domains[event.name]:
237 return True 237 return True
238 return False 238 return False
239 # Implement other event masking here on self.eventmask 239 eid = str(event.__class__)[8:-2]
240 if eid not in self.eventmask:
241 return False
240 return True 242 return True
241 243
244def set_UIHmask(handlerNum, level, debug_domains, mask):
245 if not handlerNum in _ui_handlers:
246 return False
247 if '*' in mask:
248 _ui_logfilters[handlerNum].update(None, level, debug_domains)
249 else:
250 _ui_logfilters[handlerNum].update(mask, level, debug_domains)
251 return True
252
242def getName(e): 253def getName(e):
243 """Returns the name of a class or class instance""" 254 """Returns the name of a class or class instance"""
244 if getattr(e, "__name__", None) == None: 255 if getattr(e, "__name__", None) == None:
diff --git a/bitbake/lib/bb/server/process.py b/bitbake/lib/bb/server/process.py
index 99a6bf5..e2cec49 100644
--- a/bitbake/lib/bb/server/process.py
+++ b/bitbake/lib/bb/server/process.py
@@ -37,8 +37,9 @@ from . import BitBakeBaseServer, BitBakeBaseServerConnection, BaseImplServer
37logger = logging.getLogger('BitBake') 37logger = logging.getLogger('BitBake')
38 38
39class ServerCommunicator(): 39class ServerCommunicator():
40 def __init__(self, connection): 40 def __init__(self, connection, event_handle):
41 self.connection = connection 41 self.connection = connection
42 self.event_handle = event_handle
42 43
43 def runCommand(self, command): 44 def runCommand(self, command):
44 # @todo try/except 45 # @todo try/except
@@ -54,6 +55,8 @@ class ServerCommunicator():
54 except KeyboardInterrupt: 55 except KeyboardInterrupt:
55 pass 56 pass
56 57
58 def getEventHandle(self):
59 return self.event_handle.value
57 60
58class EventAdapter(): 61class EventAdapter():
59 """ 62 """
@@ -84,11 +87,12 @@ class ProcessServer(Process, BaseImplServer):
84 87
85 self.keep_running = Event() 88 self.keep_running = Event()
86 self.keep_running.set() 89 self.keep_running.set()
90 self.event_handle = multiprocessing.Value("i")
87 91
88 def run(self): 92 def run(self):
89 for event in bb.event.ui_queue: 93 for event in bb.event.ui_queue:
90 self.event_queue.put(event) 94 self.event_queue.put(event)
91 self.event_handle = bb.event.register_UIHhandler(self) 95 self.event_handle.value = bb.event.register_UIHhandler(self)
92 bb.cooker.server_main(self.cooker, self.main) 96 bb.cooker.server_main(self.cooker, self.main)
93 97
94 def main(self): 98 def main(self):
@@ -106,7 +110,7 @@ class ProcessServer(Process, BaseImplServer):
106 logger.exception('Running command %s', command) 110 logger.exception('Running command %s', command)
107 111
108 self.event_queue.close() 112 self.event_queue.close()
109 bb.event.unregister_UIHhandler(self.event_handle) 113 bb.event.unregister_UIHhandler(self.event_handle.value)
110 self.command_channel.close() 114 self.command_channel.close()
111 self.cooker.stop() 115 self.cooker.stop()
112 self.idle_commands(.1) 116 self.idle_commands(.1)
@@ -147,7 +151,7 @@ class BitBakeProcessServerConnection(BitBakeBaseServerConnection):
147 self.procserver = serverImpl 151 self.procserver = serverImpl
148 self.ui_channel = ui_channel 152 self.ui_channel = ui_channel
149 self.event_queue = event_queue 153 self.event_queue = event_queue
150 self.connection = ServerCommunicator(self.ui_channel) 154 self.connection = ServerCommunicator(self.ui_channel, self.procserver.event_handle)
151 self.events = self.event_queue 155 self.events = self.event_queue
152 156
153 def terminate(self): 157 def terminate(self):
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index d290550..4dee5d9 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -95,7 +95,8 @@ class BitBakeServerCommands():
95 """ 95 """
96 s, t = _create_server(host, port) 96 s, t = _create_server(host, port)
97 97
98 return bb.event.register_UIHhandler(s) 98 self.event_handle = bb.event.register_UIHhandler(s)
99 return self.event_handle
99 100
100 def unregisterEventHandler(self, handlerNum): 101 def unregisterEventHandler(self, handlerNum):
101 """ 102 """
@@ -109,6 +110,9 @@ class BitBakeServerCommands():
109 """ 110 """
110 return self.cooker.command.runCommand(command, self.server.readonly) 111 return self.cooker.command.runCommand(command, self.server.readonly)
111 112
113 def getEventHandle(self):
114 return self.event_handle
115
112 def terminateServer(self): 116 def terminateServer(self):
113 """ 117 """
114 Trigger the server to quit 118 Trigger the server to quit
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 09ad99e..1692e32 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -232,6 +232,15 @@ def _log_settings_from_server(server):
232 raise BaseException(error) 232 raise BaseException(error)
233 return includelogs, loglines, consolelogfile 233 return includelogs, loglines, consolelogfile
234 234
235_evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.LogRecord",
236 "bb.build.TaskFailed", "bb.build.TaskBase", "bb.event.ParseStarted",
237 "bb.event.ParseProgress", "bb.event.ParseCompleted", "bb.event.CacheLoadStarted",
238 "bb.event.CacheLoadProgress", "bb.event.CacheLoadCompleted", "bb.command.CommandFailed",
239 "bb.command.CommandExit", "bb.command.CommandCompleted", "bb.cooker.CookerExit",
240 "bb.event.MultipleProviders", "bb.event.NoProvider", "bb.runqueue.sceneQueueTaskStarted",
241 "bb.runqueue.runQueueTaskStarted", "bb.runqueue.runQueueTaskFailed", "bb.runqueue.sceneQueueTaskFailed",
242 "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent"]
243
235def main(server, eventHandler, params, tf = TerminalFilter): 244def main(server, eventHandler, params, tf = TerminalFilter):
236 245
237 includelogs, loglines, consolelogfile = _log_settings_from_server(server) 246 includelogs, loglines, consolelogfile = _log_settings_from_server(server)
@@ -262,6 +271,9 @@ def main(server, eventHandler, params, tf = TerminalFilter):
262 consolelog.setFormatter(conlogformat) 271 consolelog.setFormatter(conlogformat)
263 logger.addHandler(consolelog) 272 logger.addHandler(consolelog)
264 273
274 llevel, debug_domains = bb.msg.constructLogOptions()
275 server.runCommand(["setEventMask", server.getEventHandle(), llevel, debug_domains, _evt_list])
276
265 if not params.observe_only: 277 if not params.observe_only:
266 params.updateFromServer(server) 278 params.updateFromServer(server)
267 cmdline = params.parseActions() 279 cmdline = params.parseActions()