]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
bitbake: event/command: Allow UI to request the UI eventhander ID
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 18 Jul 2017 21:01:15 +0000 (22:01 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 21 Jul 2017 07:41:11 +0000 (08:41 +0100)
The UI may want to change its event mask however to do this, it needs the
event handler's ID. Tweak the code to allow this to be stored and add
a command to query it.

Use the new command in the process server backend.

(Bitbake rev: f8cf2cb58b80ce74f756a11a9773b6b0e78d51ee)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
bitbake/lib/bb/command.py
bitbake/lib/bb/event.py
bitbake/lib/bb/server/process.py

index 36891b923f61b4102209d69bc4a931a1f0286d4e..eb7c86f4fe4a7542c9f2c920957681c22edf70d0 100644 (file)
@@ -238,6 +238,11 @@ class CommandsSync:
         return command.cooker.matchFile(fMatch)
     matchFile.needconfig = False
 
+    def getUIHandlerNum(self, command, params):
+        return bb.event.get_uihandler()
+    getUIHandlerNum.needconfig = False
+    getUIHandlerNum.readonly = True
+
     def setEventMask(self, command, params):
         handlerNum = params[0]
         llevel = params[1]
index d5c5ef354417bf51aea66041a3cee2b26fe6fb48..92ee3e92d4af61e1ce6e448aae838d8f32c02c3c 100644 (file)
@@ -288,13 +288,13 @@ def set_eventfilter(func):
     _eventfilter = func
 
 def register_UIHhandler(handler, mainui=False):
-    if mainui:
-        global _uiready
-        _uiready = True
     bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1
     _ui_handlers[_ui_handler_seq] = handler
     level, debug_domains = bb.msg.constructLogOptions()
     _ui_logfilters[_ui_handler_seq] = UIEventFilter(level, debug_domains)
+    if mainui:
+        global _uiready
+        _uiready = _ui_handler_seq
     return _ui_handler_seq
 
 def unregister_UIHhandler(handlerNum, mainui=False):
@@ -305,6 +305,11 @@ def unregister_UIHhandler(handlerNum, mainui=False):
         del _ui_handlers[handlerNum]
     return
 
+def get_uihandler():
+    if _uiready is False:
+        return None
+    return _uiready
+
 # Class to allow filtering of events and specific filtering of LogRecords *before* we put them over the IPC
 class UIEventFilter(object):
     def __init__(self, level, debug_domains):
index a8ba4681c646af67cb94b5171d68dde2bed017f8..cfcd76495cbb5be47976ca6c3073a986e664456e 100644 (file)
@@ -63,7 +63,12 @@ class ServerCommunicator():
                 pass
 
     def getEventHandle(self):
-        return self.event_handle.value
+        handle, error = self.runCommand(["getUIHandlerNum"])
+        if error:
+            logger.error("Unable to get UI Handler Number: %s" % error)
+            raise BaseException(error)
+
+        return handle
 
 class EventAdapter():
     """