Changeset 3682


Ignore:
Timestamp:
Feb 20, 2011 10:12:25 PM (9 years ago)
Author:
wehart
Message:

Renaming the --logfile option to --output.

Adding a --logfile option that redirects log messages to a file.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
3 edited

Legend:

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

    r3681 r3682  
    100100        dest='debug',
    101101        default=False)
     102    group.add_argument('--logfile',
     103        help='Print log messages to the specified file.',
     104        action='store',
     105        dest='logfile',
     106        default=None)
    102107    return group
    103108
     
    155160        type=int,
    156161        default=0)
     162    group.add_argument('--stream-solver',
     163        help='Stream the solver output to provide information about the '     \
     164             "solver's progress.",
     165        action='store_true',
     166        dest='tee',
     167        default=False)
    157168    return group
    158169
     
    173184        dest='log',
    174185        default=False)
    175     group.add_argument('--logfile',
    176         help='Redirect output to the specified logfile',
    177         action='store',
    178         dest='logfile',
    179         default=None)
    180186    group.add_argument('--save-results',
    181187        help='Specify the filename to which the results are saved.',
     
    183189        dest='save_results',
    184190        default=None)
    185     group.add_argument('--stream-output',
    186         help='Stream the solver output to provide information about the '     \
    187              "solver's progress.",
    188         action='store_true',
    189         dest='tee',
    190         default=False)
    191191    group.add_argument('-s','--summary',
    192192        help='Summarize the final solution after performing optimization',
     
    206206    group = parser.add_argument_group('Miscellaneous Options')
    207207
     208    group.add_argument('--output',
     209        help='Redirect output to the specified file',
     210        action='store',
     211        dest='output',
     212        default=None)
    208213    group.add_argument('--disable-gc',
    209214        help='Disable the garbage collecter',
  • coopr.pyomo/trunk/coopr/pyomo/scripting/util.py

    r3681 r3682  
    652652        logging.getLogger('coopr').setLevel(logging.DEBUG)
    653653        logging.getLogger('pyutilib').setLevel(logging.DEBUG)
    654     #
    655     # Setup I/O redirect to a logfile
    656     #
    657     logfile = getattr(options, 'logfile', None)
     654    if options.logfile:
     655        logging.getLogger('coopr.pyomo').handlers = []
     656        logging.getLogger('coopr').handlers = []
     657        logging.getLogger('pyutilib').handlers = []
     658        logging.getLogger('coopr.pyomo').addHandler( logging.FileHandler(options.logfile, 'w'))
     659        logging.getLogger('coopr').addHandler( logging.FileHandler(options.logfile, 'w'))
     660        logging.getLogger('pyutilib').addHandler( logging.FileHandler(options.logfile, 'w'))
     661    #
     662    # Setup I/O redirect to a file
     663    #
     664    logfile = getattr(options, 'output', None)
    658665    if not logfile is None:
    659666        pyutilib.misc.setup_redirect(logfile)
  • coopr.pyomo/trunk/coopr/pyomo/tests/examples/test_pyomo.py

    r3680 r3682  
    113113
    114114    def test12(self):
    115         """Run pyomo with --logfile option"""
     115        """Run pyomo with --output option"""
    116116        def filter(line):
    117117            #print "HERE",line
    118118            return line.startswith("Writing")
    119         self.pyomo('--logfile=%s pmedian.py pmedian.dat' % (currdir+'test12.log'), file=currdir+'test12.out')
     119        self.pyomo('--output=%s pmedian.py pmedian.dat' % (currdir+'test12.log'), file=currdir+'test12.out')
    120120        self.failUnlessFileEqualsBaseline(currdir+"test12.log", currdir+"test12.txt", filter)
    121121        os.remove(currdir+'test12.out')
Note: See TracChangeset for help on using the changeset viewer.