From: Jason Stubbs Date: Fri, 23 Dec 2005 02:46:03 +0000 (-0000) Subject: Generalize portage_util.dump_traceback() and make use of it if importing X-Git-Tag: v2.1_pre2~7 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=853882e3805e31de0e732b5467cd6d8a76bb2a86;p=portage.git Generalize portage_util.dump_traceback() and make use of it if importing a cache module fails. svn path=/main/trunk/; revision=2439 --- 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)