Changeset 3409


Ignore:
Timestamp:
Jan 3, 2011 12:45:38 AM (9 years ago)
Author:
wehart
Message:

Various bug fixes in the logic for call-back functions. (I guess these weren't well
tested so far...)

Converting command-line options into a pyutilib.misc.Options object.

File:
1 edited

Legend:

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

    r3408 r3409  
    1313import textwrap
    1414import traceback
     15import types
    1516try:
    1617    import cProfile as profile
     
    3637filter_excepthook=False
    3738modelapi = {    'pyomo_create_model':IPyomoScriptCreateModel,
    38                 'pyomo_creat_modeldata':IPyomoScriptCreateModelData,
     39                'pyomo_create_modeldata':IPyomoScriptCreateModelData,
    3940                'pyomo_print_model':IPyomoScriptPrintModel,
     41                'pyomo_modify_instance':IPyomoScriptModifyInstance,
    4042                'pyomo_print_instance':IPyomoScriptPrintInstance,
    41                 'pyomo_modify_instance':IPyomoScriptModifyInstance,
    4243                'pyomo_save_instance':IPyomoScriptSaveInstance,
    4344                'pyomo_print_results':IPyomoScriptPrintResults,
     
    289290
    290291    if len(ep) == 1:
    291         modeldata = ep.apply( options=options, model=model )
     292        modeldata = ep.service().apply( options=options, model=model )
    292293    else:
    293294        modeldata = ModelData()
     
    352353    else:
    353354       if hasattr(options,"profile_memory"):
    354           instance = model.create(profile_memory=options.profile_memory)
     355          instance = model.create(modeldata, profile_memory=options.profile_memory)
    355356       else:
    356           instance = model.create()
     357          instance = model.create(modeldata)
    357358
    358359    if hasattr(options, "linearize_expressions") and (options.linearize_expressions is True):
     
    525526    #
    526527    try:
    527        (options, nargs) = parser.parse_args(args=args)
     528       (_options, nargs) = parser.parse_args(args=args)
     529       # Replace the parser options object with a pyutilib.misc.Options object
     530       options = pyutilib.misc.Options()
     531       for key in dir(_options):
     532            if key[0] != '_':
     533                val = getattr(_options, key)
     534                if not isinstance(val, types.MethodType):
     535                    options[key] = val
    528536    except SystemExit:
    529537       # the parser throws a system exit if "-h" is specified - catch
Note: See TracChangeset for help on using the changeset viewer.