summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Stubbs <jstubbs@gentoo.org>2005-12-23 02:46:03 +0000
committerJason Stubbs <jstubbs@gentoo.org>2005-12-23 02:46:03 +0000
commit853882e3805e31de0e732b5467cd6d8a76bb2a86 (patch)
tree65c8df6bacdcd7e7786928ea74a2497991b75457
parent57271bf98ed6d7c318a4e78924e9b4b654a566a4 (diff)
downloadportage-853882e3805e31de0e732b5467cd6d8a76bb2a86.tar.gz
portage-853882e3805e31de0e732b5467cd6d8a76bb2a86.tar.bz2
portage-853882e3805e31de0e732b5467cd6d8a76bb2a86.zip
Generalize portage_util.dump_traceback() and make use of it if importing
a cache module fails. svn path=/main/trunk/; revision=2439
-rw-r--r--pym/portage.py4
-rw-r--r--pym/portage_util.py22
2 files changed, 17 insertions, 9 deletions
diff --git a/pym/portage.py b/pym/portage.py
index 536795ecc..851dab39c 100644
--- a/pym/portage.py
+++ b/pym/portage.py
@@ -1284,7 +1284,7 @@ class config:
try:
mod = load_mod(best_mod)
except:
- writemsg(red("!!! Failed to import module '%s'\n") % best_mod)
+ dump_traceback(red("Error: Failed to import module '%s'") % best_mod, noiselevel=0)
sys.exit(1)
return mod
@@ -2426,7 +2426,7 @@ def doebuild(myebuild,mydo,myroot,mysettings,debug=0,listonly=0,fetchonly=0,clea
global db, actionmap_deps
if not tree:
- dump_traceback("tree not specified to doebuild")
+ dump_traceback("Warning: tree not specified to doebuild")
tree = "porttree"
ebuild_path = os.path.abspath(myebuild)
diff --git a/pym/portage_util.py b/pym/portage_util.py
index 9c521ab8a..090ce6735 100644
--- a/pym/portage_util.py
+++ b/pym/portage_util.py
@@ -456,11 +456,19 @@ def unique_array(array):
return mya
-def dump_traceback(msg):
+def dump_traceback(msg, noiselevel=1):
import sys, traceback
- writemsg("\n====================================\n", noiselevel=1)
- writemsg("Warning: %s\n" % msg, noiselevel=1)
- for line in traceback.format_list(traceback.extract_stack()[:-1]):
- writemsg(line, noiselevel=1)
- writemsg("Please file a bug for %s\n" % sys.argv[0], noiselevel=1)
- writemsg("====================================\n\n", noiselevel=1)
+ info = sys.exc_info()
+ if not info[2]:
+ stack = traceback.extract_stack()[:-1]
+ error = None
+ else:
+ stack = traceback.extract_tb(info[2])
+ error = str(info[1])
+ writemsg("\n====================================\n", noiselevel=noiselevel)
+ writemsg("%s\n\n" % msg, noiselevel=noiselevel)
+ for line in traceback.format_list(stack):
+ writemsg(line, noiselevel=noiselevel)
+ if error:
+ writemsg(error+"\n", noiselevel=noiselevel)
+ writemsg("====================================\n\n", noiselevel=noiselevel)