]> code.ossystems Code Review - openembedded-core.git/commitdiff
Display python warnings via bb.msg
authorChris Larson <chris_larson@mentor.com>
Fri, 9 Apr 2010 22:55:55 +0000 (15:55 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 2 Jul 2010 14:41:32 +0000 (15:41 +0100)
(Bitbake rev: 648415a562d92109c4945cb3cc98ed2ec44667a7)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/bin/bitbake

index c2088d93207d5c71c07e6a8c8373ad488ae74665..8fdb6540a215a1f76ada1e617621050358b9b85d 100755 (executable)
 
 import sys, os, getopt, re, time, optparse, xmlrpclib
 sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib'))
+
+import warnings
 import bb
+import bb.msg
 from bb import cooker
 from bb import ui
 from bb import server
@@ -60,6 +63,21 @@ def print_exception(exc, value, tb):
 
     sys.__excepthook__(exc, value, tb)
 
+sys.excepthook = print_exception
+
+
+_warnings_showwarning = warnings.showwarning
+def _showwarning(message, category, filename, lineno, file=None, line=None):
+    """Display python warning messages using bb.msg"""
+    if file is not None:
+        if _warnings_showwarning is not None:
+            _warnings_showwarning(message, category, filename, lineno, file, line)
+    else:
+        s = warnings.formatwarning(message, category, filename, lineno)
+        s = s.split("\n")[0]
+        bb.msg.warn(None, s)
+
+warnings.showwarning = _showwarning
 
 #============================================================================#
 # main
@@ -169,8 +187,6 @@ Default BBFILES are the .bb files in the current directory.""" )
     server.BitBakeServerFork(serverinfo, cooker.serve, cooker_logfile)
     del cooker
 
-    sys.excepthook = print_exception
-
     # Setup a connection to the server (cooker)
     serverConnection = server.BitBakeServerConnection(serverinfo)