mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
Consolidate the exec/eval bits, switch anonfunc to better_exec, etc
The methodpool, ${@} expansions, anonymous python functions, event handlers
now all run with the same global context, ensuring a consistent environment
for them. Added a bb.utils.better_eval function which does an eval() with the
same globals as better_exec.
(Bitbake rev: 424d7e267b009cc19b8503eadab782736d9597d0)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
committed by
Richard Purdie
parent
eb16773704
commit
94b60d1247
+14
-4
@@ -21,9 +21,16 @@ BitBake Utility Functions
|
||||
|
||||
separators = ".-"
|
||||
|
||||
import re, fcntl, os, types, bb, string, stat, shutil
|
||||
import re, fcntl, os, types, bb, string, stat, shutil, time
|
||||
from commands import getstatusoutput
|
||||
|
||||
# Context used in better_exec, eval
|
||||
_context = {
|
||||
"os": os,
|
||||
"bb": bb,
|
||||
"time": time,
|
||||
}
|
||||
|
||||
def explode_version(s):
|
||||
r = []
|
||||
alpha_regexp = re.compile('^([a-zA-Z]+)(.*)$')
|
||||
@@ -164,13 +171,13 @@ def _print_trace(body, line):
|
||||
bb.msg.error(bb.msg.domain.Util, "\t%.4d:%s" % (i, body[i-1]) )
|
||||
|
||||
|
||||
def better_compile(text, file, realfile):
|
||||
def better_compile(text, file, realfile, mode = "exec"):
|
||||
"""
|
||||
A better compile method. This method
|
||||
will print the offending lines.
|
||||
"""
|
||||
try:
|
||||
return compile(text, file, "exec")
|
||||
return compile(text, file, mode)
|
||||
except Exception, e:
|
||||
import bb,sys
|
||||
|
||||
@@ -193,7 +200,7 @@ def better_exec(code, context, text, realfile):
|
||||
"""
|
||||
import bb,sys
|
||||
try:
|
||||
exec code in context
|
||||
exec code in _context, context
|
||||
except:
|
||||
(t,value,tb) = sys.exc_info()
|
||||
|
||||
@@ -215,6 +222,9 @@ def better_exec(code, context, text, realfile):
|
||||
|
||||
raise
|
||||
|
||||
def better_eval(source, locals):
|
||||
return eval(source, _context, locals)
|
||||
|
||||
def Enum(*names):
|
||||
"""
|
||||
A simple class to give Enum support
|
||||
|
||||
Reference in New Issue
Block a user