aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2006-03-07 20:21:51 +0000
committerHolger Hans Peter Freyther <zecke@selfish.org>2006-03-07 20:21:51 +0000
commit170b111819a30df7c9e7d5423ef614ad121272dd (patch)
tree877a4d6566a094797874e2ae7694cd85e3fc9a87
parent47c54dc6793f3ba77dfacc8a24dbb91da362cd64 (diff)
downloadbitbake-170b111819a30df7c9e7d5423ef614ad121272dd.tar.gz
bitbake/lib/bb/utils.py:
Create a work in progress version for better_execute. With advanced error reporting facilities. bitbake/lib/bb/build.py: Use better_execute bitbake/parse/parse_py/BBHandler.py: Use better_execute instead of exex
-rw-r--r--lib/bb/build.py2
-rw-r--r--lib/bb/parse/parse_py/BBHandler.py2
-rw-r--r--lib/bb/utils.py32
3 files changed, 34 insertions, 2 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index 5a72be73b..b59473bc2 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -130,7 +130,7 @@ def exec_func_python(func, d):
g['bb'] = bb
g['os'] = os
g['d'] = d
- exec comp in g
+ utils.better_exec(comp,g,tmp, bb.data.getVar('FILE',d,1))
if os.path.exists(prevdir):
os.chdir(prevdir)
diff --git a/lib/bb/parse/parse_py/BBHandler.py b/lib/bb/parse/parse_py/BBHandler.py
index d083bb312..422ce6f9e 100644
--- a/lib/bb/parse/parse_py/BBHandler.py
+++ b/lib/bb/parse/parse_py/BBHandler.py
@@ -207,7 +207,7 @@ def feeder(lineno, s, fn, d):
else:
text = '\n'.join(__body__)
comp = bb.utils.better_compile(text, "<bb>", fn )
- exec comp in __builtins__
+ bb.utils.better_exec(comp, __builtins__, text, fn)
__body__ = []
__inpython__ = False
funcs = data.getVar('__functions__', d) or ""
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 31dc4e372..53c874f8c 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -96,6 +96,10 @@ def explode_deps(s):
def better_compile(text, file, realfile):
+ """
+ A better compile method. This method
+ will print the offending lines.
+ """
try:
return compile(text, file, "exec")
except Exception, e:
@@ -116,3 +120,31 @@ def better_compile(text, file, realfile):
# exit now
sys.exit(1)
+def better_exec(code, context, text, realfile):
+ """
+ Similiar to better_compile, better_exec will
+ print the lines that are responsible for the
+ error.
+ """
+ import bb,sys
+ try:
+ bb.note("executing")
+ exec code in context
+ except:
+ (t,value,tb) = sys.exc_info()
+ bb.note("error")
+
+ import traceback
+ print type(t)
+ print type(value)
+ print type(tb)
+ print t
+ print value
+ print tb
+ print dir(tb)
+ while tb.tb_next:
+ tb = tb.tb_next
+
+ print "f:%d" %traceback.tb_lineno(tb)
+ traceback.print_tb(tb)
+ raise