Index: wflow-py/Scripts/bmi2runner.py =================================================================== diff -u -r59cffa03cc52cdb4dc62a0ead1aafb6bc039b430 -rb90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0 --- wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision 59cffa03cc52cdb4dc62a0ead1aafb6bc039b430) +++ wflow-py/Scripts/bmi2runner.py (.../bmi2runner.py) (revision b90c267fae9ec3423464cf9b6c7a9bcbcd45d3a0) @@ -30,10 +30,12 @@ import getopt import logging + def usage(*args): sys.stdout = sys.stderr """Way""" - for msg in args: print(msg) + for msg in args: + print(msg) print(__doc__) sys.exit(0) @@ -45,7 +47,6 @@ configfile = "bmirunner.ini" - if argv is None: argv = sys.argv[1:] if len(argv) == 0: @@ -55,52 +56,51 @@ ## Process command-line options # ######################################################################## try: - opts, args = getopt.getopt(argv, 'c:l:') + opts, args = getopt.getopt(argv, "c:l:") except getopt.error as msg: usage(msg) - loglevel=logging.WARN + loglevel = logging.WARN for o, a in opts: - if o == '-c': configfile = a - if o == '-l': exec("loglevel = logging." + a) + if o == "-c": + configfile = a + if o == "-l": + exec("loglevel = logging." + a) + combilogger = pcrut.setlogger( + "bmi2runner.log", "bmi2runner_logging", thelevel=loglevel + ) - - combilogger = pcrut.setlogger("bmi2runner.log", "bmi2runner_logging", thelevel=loglevel) - # Construct object and initilize the models combilogger.info("Starting combined bmi object") bmiobj = wfbmi.wflowbmi_csdms() - + bmiobj.initialize_config(configfile, loglevel=loglevel) bmiobj.initialize_model() - + # Get and set start and end times start = bmiobj.get_start_time() end = bmiobj.get_end_time() bmiobj.set_start_time(start) bmiobj.set_end_time(end) - + # Update models (if necessary) to start time bmiobj.update_to_start_time(start) - + # Number of steps to run models ts = bmiobj.get_time_step() steps = int((end - start) / ts + 1) - + cts = bmiobj.currenttimestep # Loop over the time duration while cts < steps: combilogger.info("time is: " + str(bmiobj.get_current_time())) bmiobj.update() cts = bmiobj.currenttimestep - - + bmiobj.finalize() combilogger.info("Finishing run") if __name__ == "__main__": main() - -