]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
build: fix file mode for /dev/null
authorChris Larson <chris_larson@mentor.com>
Fri, 17 Dec 2010 18:01:51 +0000 (11:01 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 17 Dec 2010 18:01:51 +0000 (11:01 -0700)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
lib/bb/build.py
lib/bb/utils.py

index 5e494deff0d141b37fecb04eba58ea8b1b420c6b..5f3986b1edc742b011ce2fecec0614a911f52d58 100644 (file)
@@ -37,7 +37,7 @@ from bb import data, event, utils
 bblogger = logging.getLogger('BitBake')
 logger = logging.getLogger('BitBake.Build')
 
-NULL = open('/dev/null', 'a')
+NULL = open('/dev/null', 'r+')
 
 
 class FuncFailed(Exception):
index 986f94f3f3bc00bcaef9f53765e41d5ea95545e4..f5e4b60ab03adcd03a57152bd6e589bf0bd29a29 100644 (file)
@@ -297,12 +297,10 @@ def _print_trace(body, line):
     """
     # print the environment of the method
     min_line = max(1, line-4)
-    max_line = min(line + 4, len(body))
+    max_line = min(line + 4, len(body)-1)
     for i in xrange(min_line, max_line + 1):
-        if line == i:
-            logger.error(' *** %.4d:%s', i, body[i-1])
-        else:
-            logger.error('     %.4d:%s', i, body[i-1])
+        logger.error("\t%.4d:%s", i, body[i-1])
+
 
 def better_compile(text, file, realfile, mode = "exec"):
     """
@@ -344,38 +342,21 @@ def better_exec(code, context, text, realfile = "<code>"):
         if t in [bb.parse.SkipPackage, bb.build.FuncFailed]:
             raise
 
-        logger.error('There was an error when executing a python function in: %s', realfile)
+        logger.exception("Error executing python function in '%s'", code.co_filename)
 
         # Strip 'us' from the stack (better_exec call)
         tb = tb.tb_next
 
         import traceback
-        textarray = text.split('\n')
-        linefailed = traceback.tb_lineno(tb)
-
         tbextract = traceback.extract_tb(tb)
-        tbformat = "\n".join(traceback.format_list(tbextract))
-        logger.error("The stack trace of python calls that resulted in thie exception/failure was:")
-        for line in tbformat.split('\n'):
-            logger.error(line)
-
-        logger.error("The code that was being executed was:")
-        _print_trace(textarray, linefailed)
-        logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[0][0], tbextract[0][1], tbextract[0][2])
-
-        # See if this is a function we constructed and has calls back into other functions in
-        # "text". If so, try and improve the context of the error by diving down the trace
-        level = 0
-        nexttb = tb.tb_next
-        while nexttb is not None:
-            if tbextract[level][0] == tbextract[level+1][0] and tbextract[level+1][2] == tbextract[level][0]:
-                _print_trace(textarray, tbextract[level+1][1])
-                logger.error("(file: '%s', lineno: %s, function: %s)", tbextract[level+1][0], tbextract[level+1][1], tbextract[level+1][2])
-            else:
-                 break
-            nexttb = tb.tb_next
-            level = level + 1
-
+        tbextract = "\n".join(traceback.format_list(tbextract))
+        bb.msg.error(bb.msg.domain.Util, "Traceback:")
+        for line in tbextract.split('\n'):
+            bb.msg.error(bb.msg.domain.Util, line)
+
+        line = traceback.tb_lineno(tb)
+        bb.msg.error(bb.msg.domain.Util, "The lines leading to this error were:")
+        _print_trace( text.split('\n'), line )
         raise
 
 def simple_exec(code, context):