diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-04-09 15:55:55 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-04-09 15:59:34 -0700 |
commit | 648415a562d92109c4945cb3cc98ed2ec44667a7 (patch) | |
tree | 7239f09a29329c9dca6c5f5beb931ee054bf4f4d /bin/bitbake | |
parent | 17c414d0c050c42d4beb3f1dd84573020aacb392 (diff) | |
download | bitbake-648415a562d92109c4945cb3cc98ed2ec44667a7.tar.gz |
Display python warnings via bb.msg
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'bin/bitbake')
-rwxr-xr-x | bin/bitbake | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bin/bitbake b/bin/bitbake index 1bcf8134c..b8f60aad9 100755 --- a/bin/bitbake +++ b/bin/bitbake @@ -24,7 +24,10 @@ 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 @@ -166,8 +184,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) |