Changeset 2399


Ignore:
Timestamp:
Feb 24, 2010 1:36:56 PM (10 years ago)
Author:
wehart
Message:

Adding a work-around when pstats cannot be imported.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r2283 r2399  
    1414import traceback
    1515import cProfile
    16 import pstats
     16try:
     17    import pstats
     18    pstats_available=True
     19except ImportError:
     20    pstats_available=False
    1721import gc
    1822from coopr.pyomo import *
     
    319323    #
    320324    if options.profile > 0:
     325        if not pstats_available:
     326            raise ValueError, "Cannot use the 'profile' option.  The Python 'pstats' package cannot be imported!"
    321327        tfile = pyutilib.services.TempfileManager.create_tempfile(suffix=".profile")
    322328        tmp = cProfile.runctx(command.__name__+'(options=options,args=nargs,parser=parser)',globals(),locals(),tfile)
Note: See TracChangeset for help on using the changeset viewer.