Changeset 3088


Ignore:
Timestamp:
Oct 13, 2010 1:52:13 PM (11 years ago)
Author:
jwatson
Message:

Added --traceback option to runph, in order to dump the full stack trace when an exception is thrown.

Location:
coopr.pysp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/phinit.py

    r3065 r3088  
    296296     default=False)
    297297
    298 
    299298   otherOpts.add_option('--disable-gc',
    300299     help="Disable the python garbage collecter. Default is False.",
     
    319318     type="int",
    320319     default=0)
    321    
    322 
    323    
     320   otherOpts.add_option('--traceback',
     321     help="When an exception is thrown, show the entire call stack. Ignored if profiling is enabled. Default is False.",
     322     action="store_true",
     323     dest="traceback",
     324     default=False)   
    324325
    325326   return parser
     
    726727        # Call the main PH routine without profiling.
    727728        #
    728         ans = exec_ph(options)
     729
     730        if options.traceback is True:
     731           ans = exec_ph(options)
     732        else:
     733           try:
     734              ans = exec_ph(options)
     735           except ValueError, str:
     736              print "VALUE ERROR:"
     737              print str
     738           except TypeError, str:
     739              print "TYPE ERROR:"
     740              print str
     741           except NameError, str:
     742              print "NAME ERROR:"
     743              print str                           
     744           except IOError, str:
     745              print "IO ERROR:"
     746              print str
     747           except pyutilib.common.ApplicationError, str:
     748              print "APPLICATION ERROR:"
     749              print str
     750           except RuntimeError, str:
     751              print "RUN-TIME ERROR:"   
     752              print str       
     753           except:
     754              print "Encountered unhandled exception"
     755              traceback.print_exc()
     756           sys.exit(0)
    729757
    730758    gc.enable()
  • coopr.pysp/trunk/scripts/runph

    r2261 r3088  
    4848import coopr.pysp.phinit
    4949
    50 try:
    51     coopr.pysp.phinit.run()
    52 except ValueError, str:
    53     print "VALUE ERROR:"
    54     print str
    55 except IOError, str:
    56     print "IO ERROR:"
    57     print str
    58 except pyutilib.common.ApplicationError, str:
    59     print "APPLICATION ERROR:"
    60     print str
    61 except RuntimeError, str:
    62     print "RUN-TIME ERROR:"   
    63     print str       
    64 except:
    65    print "Encountered unhandled exception"
    66    traceback.print_exc()
     50coopr.pysp.phinit.run()
     51
Note: See TracChangeset for help on using the changeset viewer.