summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
committerRichard Purdie <richard@openedhand.com>2006-03-20 17:45:11 +0000
commitb26a945734ce271aa7d443ff9e96fe2851b21138 (patch)
treef540b8d58a7411cf0cabe5c8f4ad40f9f597352a /bitbake/lib/bb/event.py
parent3cd47ad235d54a9c539ae6fe4a5a2b4b5f7e5621 (diff)
downloadpoky-b26a945734ce271aa7d443ff9e96fe2851b21138.tar.gz
Update to latest bitbake
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@309 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r--bitbake/lib/bb/event.py66
1 files changed, 55 insertions, 11 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index c4e88fa35d..cbe6d2a11a 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -25,6 +25,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA.
25 25
26import os, re 26import os, re
27import bb.data 27import bb.data
28import bb.utils
28 29
29class Event: 30class Event:
30 """Base class for events""" 31 """Base class for events"""
@@ -50,8 +51,8 @@ def tmpHandler(event):
50 return NotHandled 51 return NotHandled
51 52
52def defaultTmpHandler(): 53def defaultTmpHandler():
53 tmp = "def tmpHandler(e):\n\t\"\"\"heh\"\"\"\n\treturn 0" 54 tmp = "def tmpHandler(e):\n\t\"\"\"heh\"\"\"\n\treturn NotHandled"
54 comp = compile(tmp, "tmpHandler(e)", "exec") 55 comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event.defaultTmpHandler")
55 return comp 56 return comp
56 57
57def fire(event): 58def fire(event):
@@ -71,12 +72,12 @@ def register(handler):
71 if handler is not None: 72 if handler is not None:
72# handle string containing python code 73# handle string containing python code
73 if type(handler).__name__ == "str": 74 if type(handler).__name__ == "str":
74 return registerCode(handler) 75 return _registerCode(handler)
75# prevent duplicate registration 76# prevent duplicate registration
76 if not handler in handlers: 77 if not handler in handlers:
77 handlers.append(handler) 78 handlers.append(handler)
78 79
79def registerCode(handlerStr): 80def _registerCode(handlerStr):
80 """Register a 'code' Event. 81 """Register a 'code' Event.
81 Deprecated interface; call register instead. 82 Deprecated interface; call register instead.
82 83
@@ -85,7 +86,7 @@ def registerCode(handlerStr):
85 the code will be within a function, so should have had 86 the code will be within a function, so should have had
86 appropriate tabbing put in place.""" 87 appropriate tabbing put in place."""
87 tmp = "def tmpHandler(e):\n%s" % handlerStr 88 tmp = "def tmpHandler(e):\n%s" % handlerStr
88 comp = compile(tmp, "tmpHandler(e)", "exec") 89 comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._registerCode")
89# prevent duplicate registration 90# prevent duplicate registration
90 if not comp in handlers: 91 if not comp in handlers:
91 handlers.append(comp) 92 handlers.append(comp)
@@ -94,16 +95,16 @@ def remove(handler):
94 """Remove an Event handler""" 95 """Remove an Event handler"""
95 for h in handlers: 96 for h in handlers:
96 if type(handler).__name__ == "str": 97 if type(handler).__name__ == "str":
97 return removeCode(handler) 98 return _removeCode(handler)
98 99
99 if handler is h: 100 if handler is h:
100 handlers.remove(handler) 101 handlers.remove(handler)
101 102
102def removeCode(handlerStr): 103def _removeCode(handlerStr):
103 """Remove a 'code' Event handler 104 """Remove a 'code' Event handler
104 Deprecated interface; call remove instead.""" 105 Deprecated interface; call remove instead."""
105 tmp = "def tmpHandler(e):\n%s" % handlerStr 106 tmp = "def tmpHandler(e):\n%s" % handlerStr
106 comp = compile(tmp, "tmpHandler(e)", "exec") 107 comp = bb.utils.better_compile(tmp, "tmpHandler(e)", "bb.event._removeCode")
107 handlers.remove(comp) 108 handlers.remove(comp)
108 109
109def getName(e): 110def getName(e):
@@ -117,7 +118,7 @@ def getName(e):
117class PkgBase(Event): 118class PkgBase(Event):
118 """Base class for package events""" 119 """Base class for package events"""
119 120
120 def __init__(self, t, d = {}): 121 def __init__(self, t, d = bb.data.init()):
121 self._pkg = t 122 self._pkg = t
122 Event.__init__(self, d) 123 Event.__init__(self, d)
123 124
@@ -133,10 +134,11 @@ class PkgBase(Event):
133class BuildBase(Event): 134class BuildBase(Event):
134 """Base class for bbmake run events""" 135 """Base class for bbmake run events"""
135 136
136 def __init__(self, n, p, c): 137 def __init__(self, n, p, c, failures = 0):
137 self._name = n 138 self._name = n
138 self._pkgs = p 139 self._pkgs = p
139 Event.__init__(self, c) 140 Event.__init__(self, c)
141 self._failures = failures
140 142
141 def getPkgs(self): 143 def getPkgs(self):
142 return self._pkgs 144 return self._pkgs
@@ -156,6 +158,12 @@ class BuildBase(Event):
156 def setCfg(self, cfg): 158 def setCfg(self, cfg):
157 self.data = cfg 159 self.data = cfg
158 160
161 def getFailures(self):
162 """
163 Return the number of failed packages
164 """
165 return self._failures
166
159 pkgs = property(getPkgs, setPkgs, None, "pkgs property") 167 pkgs = property(getPkgs, setPkgs, None, "pkgs property")
160 name = property(getName, setName, None, "name property") 168 name = property(getName, setName, None, "name property")
161 cfg = property(getCfg, setCfg, None, "cfg property") 169 cfg = property(getCfg, setCfg, None, "cfg property")
@@ -204,7 +212,43 @@ class UnsatisfiedDep(DepBase):
204class RecursiveDep(DepBase): 212class RecursiveDep(DepBase):
205 """Recursive Dependency""" 213 """Recursive Dependency"""
206 214
215class NoProvider(Event):
216 """No Provider for an Event"""
217
218 def __init__(self, item, data,runtime=False):
219 Event.__init__(self, data)
220 self._item = item
221 self._runtime = runtime
222
223 def getItem(self):
224 return self._item
225
226 def isRuntime(self):
227 return self._runtime
207 228
208class MultipleProviders(PkgBase): 229class MultipleProviders(Event):
209 """Multiple Providers""" 230 """Multiple Providers"""
210 231
232 def __init__(self, item, candidates, data, runtime = False):
233 Event.__init__(self, data)
234 self._item = item
235 self._candidates = candidates
236 self._is_runtime = runtime
237
238 def isRuntime(self):
239 """
240 Is this a runtime issue?
241 """
242 return self._is_runtime
243
244 def getItem(self):
245 """
246 The name for the to be build item
247 """
248 return self._item
249
250 def getCandidates(self):
251 """
252 Get the possible Candidates for a PROVIDER.
253 """
254 return self._candidates