diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-04-09 15:55:55 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-07-02 15:41:32 +0100 |
commit | a91d123ef4eb315c8a44b16518fa3b40cb09fb8a (patch) | |
tree | 8ee705feab5759a22e839f07efc1054e75278d89 /bitbake/bin | |
parent | 146046bcda4e481cb221de59ac9858303d473fec (diff) | |
download | poky-a91d123ef4eb315c8a44b16518fa3b40cb09fb8a.tar.gz |
Display python warnings via bb.msg
(Bitbake rev: 648415a562d92109c4945cb3cc98ed2ec44667a7)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index c2088d9320..8fdb6540a2 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake | |||
@@ -24,7 +24,10 @@ | |||
24 | 24 | ||
25 | import sys, os, getopt, re, time, optparse, xmlrpclib | 25 | import sys, os, getopt, re, time, optparse, xmlrpclib |
26 | sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) | 26 | sys.path.insert(0,os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) |
27 | |||
28 | import warnings | ||
27 | import bb | 29 | import bb |
30 | import bb.msg | ||
28 | from bb import cooker | 31 | from bb import cooker |
29 | from bb import ui | 32 | from bb import ui |
30 | from bb import server | 33 | from bb import server |
@@ -60,6 +63,21 @@ def print_exception(exc, value, tb): | |||
60 | 63 | ||
61 | sys.__excepthook__(exc, value, tb) | 64 | sys.__excepthook__(exc, value, tb) |
62 | 65 | ||
66 | sys.excepthook = print_exception | ||
67 | |||
68 | |||
69 | _warnings_showwarning = warnings.showwarning | ||
70 | def _showwarning(message, category, filename, lineno, file=None, line=None): | ||
71 | """Display python warning messages using bb.msg""" | ||
72 | if file is not None: | ||
73 | if _warnings_showwarning is not None: | ||
74 | _warnings_showwarning(message, category, filename, lineno, file, line) | ||
75 | else: | ||
76 | s = warnings.formatwarning(message, category, filename, lineno) | ||
77 | s = s.split("\n")[0] | ||
78 | bb.msg.warn(None, s) | ||
79 | |||
80 | warnings.showwarning = _showwarning | ||
63 | 81 | ||
64 | #============================================================================# | 82 | #============================================================================# |
65 | # main | 83 | # main |
@@ -169,8 +187,6 @@ Default BBFILES are the .bb files in the current directory.""" ) | |||
169 | server.BitBakeServerFork(serverinfo, cooker.serve, cooker_logfile) | 187 | server.BitBakeServerFork(serverinfo, cooker.serve, cooker_logfile) |
170 | del cooker | 188 | del cooker |
171 | 189 | ||
172 | sys.excepthook = print_exception | ||
173 | |||
174 | # Setup a connection to the server (cooker) | 190 | # Setup a connection to the server (cooker) |
175 | serverConnection = server.BitBakeServerConnection(serverinfo) | 191 | serverConnection = server.BitBakeServerConnection(serverinfo) |
176 | 192 | ||