summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2011-04-04 09:41:41 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-06 15:47:55 +0100
commit8cf28d706b7e70f5835b1bd4da058ec64f520c6c (patch)
treec3a3987a5a330b81f066c5be88b98266aae7a738 /bitbake/lib/bb/event.py
parent2d73cd1d32171e8374a1fd77f5988b2fcba46d57 (diff)
downloadpoky-8cf28d706b7e70f5835b1bd4da058ec64f520c6c.tar.gz
event: register event handler functions, not code objects
(Bitbake rev: be647dac9d458ee4b289ff5f66ed95b311d398d8) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r--bitbake/lib/bb/event.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index ed9e4a6adc..9a07ed5c0a 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -62,18 +62,13 @@ def fire_class_handlers(event, d):
62 if isinstance(event, logging.LogRecord): 62 if isinstance(event, logging.LogRecord):
63 return 63 return
64 64
65 for handler in _handlers: 65 for handler in _handlers.itervalues():
66 h = _handlers[handler]
67 event.data = d 66 event.data = d
68 if type(h).__name__ == "code": 67 ret = handler(event)
69 locals = {"e": event} 68 if ret is not None:
70 bb.utils.simple_exec(h, locals) 69 warnings.warn("Using Handled/NotHandled in event handlers is deprecated",
71 ret = bb.utils.better_eval("tmpHandler(e)", locals) 70 DeprecationWarning, stacklevel = 2)
72 if ret is not None: 71
73 warnings.warn("Using Handled/NotHandled in event handlers is deprecated",
74 DeprecationWarning, stacklevel = 2)
75 else:
76 h(event)
77 del event.data 72 del event.data
78 73
79ui_queue = [] 74ui_queue = []
@@ -148,7 +143,10 @@ def register(name, handler):
148 if isinstance(handler, basestring): 143 if isinstance(handler, basestring):
149 tmp = "def tmpHandler(e):\n%s" % handler 144 tmp = "def tmpHandler(e):\n%s" % handler
150 comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode") 145 comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode")
151 _handlers[name] = comp 146 env = {}
147 bb.utils.simple_exec(comp, env)
148 func = bb.utils.better_eval("tmpHandler", env)
149 _handlers[name] = func
152 else: 150 else:
153 _handlers[name] = handler 151 _handlers[name] = handler
154 152