summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bitbake/doc/manual/usermanual.xml4
-rw-r--r--bitbake/lib/bb/event.py8
2 files changed, 7 insertions, 5 deletions
diff --git a/bitbake/doc/manual/usermanual.xml b/bitbake/doc/manual/usermanual.xml
index 6424a7ebd9..bd44a69e3f 100644
--- a/bitbake/doc/manual/usermanual.xml
+++ b/bitbake/doc/manual/usermanual.xml
@@ -215,13 +215,11 @@ addtask printdate before do_build</screen></para>
215 <para>BitBake allows to install event handlers. Events are triggered at certain points during operation, such as, the beginning of operation against a given .bb, the start of a given task, task failure, task success, et cetera. The intent was to make it easy to do things like email notifications on build failure.</para> 215 <para>BitBake allows to install event handlers. Events are triggered at certain points during operation, such as, the beginning of operation against a given .bb, the start of a given task, task failure, task success, et cetera. The intent was to make it easy to do things like email notifications on build failure.</para>
216 <para><screen>addhandler myclass_eventhandler 216 <para><screen>addhandler myclass_eventhandler
217python myclass_eventhandler() { 217python myclass_eventhandler() {
218 from bb.event import NotHandled, getName 218 from bb.event import getName
219 from bb import data 219 from bb import data
220 220
221 print "The name of the Event is %s" % getName(e) 221 print "The name of the Event is %s" % getName(e)
222 print "The file we run for is %s" % data.getVar('FILE', e.data, True) 222 print "The file we run for is %s" % data.getVar('FILE', e.data, True)
223
224 return NotHandled
225} 223}
226</screen></para><para> 224</screen></para><para>
227This event handler gets called every time an event is triggered. A global variable <varname>e</varname> is defined. <varname>e</varname>.data contains an instance of bb.data. With the getName(<varname>e</varname>) 225This event handler gets called every time an event is triggered. A global variable <varname>e</varname> is defined. <varname>e</varname>.data contains an instance of bb.data. With the getName(<varname>e</varname>)
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index f49f71cf71..c1c6a36c9d 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -23,6 +23,7 @@ BitBake build tools.
23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 24
25import os, re, sys 25import os, re, sys
26import warnings
26import bb.utils 27import bb.utils
27import pickle 28import pickle
28 29
@@ -38,7 +39,7 @@ class Event:
38 self.pid = worker_pid 39 self.pid = worker_pid
39 40
40NotHandled = 0 41NotHandled = 0
41Handled = 1 42Handled = 1
42 43
43Registered = 10 44Registered = 10
44AlreadyRegistered = 14 45AlreadyRegistered = 14
@@ -59,7 +60,10 @@ def fire_class_handlers(event, d):
59 if type(h).__name__ == "code": 60 if type(h).__name__ == "code":
60 locals = {"e": event} 61 locals = {"e": event}
61 bb.utils.simple_exec(h, locals) 62 bb.utils.simple_exec(h, locals)
62 bb.utils.better_eval("tmpHandler(e)", locals) 63 ret = bb.utils.better_eval("tmpHandler(e)", locals)
64 if ret is not None:
65 warnings.warn("Using Handled/NotHandled in event handlers is deprecated",
66 DeprecationWarning, stacklevel = 2)
63 else: 67 else:
64 h(event) 68 h(event)
65 del event.data 69 del event.data