def run(): """Main RHEAS routine.""" config_filename, dbname, db_update, verbose, logfile = parseArgs() if verbose: log_level = logging.DEBUG else: log_level = logging.INFO if logfile is None: logging.basicConfig(level=log_level, format='%(levelname)s: %(message)s') else: logging.basicConfig(filename=logfile, level=log_level, format='%(levelname)s: %(message)s') log = logging.getLogger(__name__) if dbname is None: dbname = "rheas" dbio.connect(dbname) # check if database update is requested if db_update: log.info("Updating database!") update(dbname, config_filename) else: options = config.loadFromFile(config_filename) # check what simulations have been requested if "nowcast" in options: nowcast.execute(dbname, options) if "forecast" in options: forecast.execute(dbname, options)
def setUp(self): self.dbname = "rheas" configfile = "{0}/tests/forecast.conf".format(rpath.data) self.options = config.loadFromFile(configfile) self.options['forecast'][ 'basin'] = "{0}/tests/basin.shp".format(rpath.data) self.options['dssat'][ 'shapefile'] = "{0}/tests/basin.shp".format(rpath.data)
def setUp(self): self.dbname = "testdb" configfile = "{0}/tests/forecast.conf".format(rpath.data) self.options = config.loadFromFile(configfile) self.options['forecast']['basin'] = "{0}/tests/basin.shp".format( rpath.data) self.options['dssat']['shapefile'] = "{0}/tests/basin.shp".format( rpath.data) tests.database.cultivars(self.dbname)
def setUp(self): """Set parameters for forecast unit tests.""" self.dbname = "testdb" configfile = "{0}/tests/forecast.conf".format(rpath.data) self.options = config.loadFromFile(configfile) self.options['forecast'][ 'basin'] = "{0}/tests/basin.shp".format(rpath.data) self.options['dssat'][ 'shapefile'] = "{0}/tests/basin.shp".format(rpath.data) tests.database.cultivars(self.dbname)
def setUp(self): self.dbname = "testdb" configfile = "{0}/tests/nowcast.conf".format(rpath.data) self.options = config.loadFromFile(configfile) self.options['nowcast'][ 'basin'] = "{0}/tests/basin.shp".format(rpath.data) self.options['dssat'][ 'shapefile'] = "{0}/tests/basin.shp".format(rpath.data) self.options['nowcast']['model'] = "vic" tests.database.cultivars(self.dbname)
def setUp(self): """Set parameters for nowcast unit tests.""" self.dbname = "testdb" configfile = "{0}/tests/nowcast.conf".format(rpath.data) self.options = config.loadFromFile(configfile) self.options['nowcast']['basin'] = "{0}/tests/basin.shp".format( rpath.data) self.options['dssat']['shapefile'] = "{0}/tests/basin.shp".format( rpath.data) self.options['nowcast']['model'] = "vic" tests.database.cultivars(self.dbname)
def run(): """Main RHEAS routine.""" config_filename, dbname, db_update = parseArgs() if dbname is None: dbname = "rheas" dbio.connect(dbname) # check if database update is requested if db_update: print "Updating database!" update(dbname, config_filename) else: options = config.loadFromFile(config_filename) # check what simulations have been requested if "nowcast" in options: nowcast.execute(dbname, options) if "forecast" in options: forecast.execute(dbname, options)
def run(): """Main RHEAS routine.""" config_filename, dbname, db_update = parseArgs() if dbname is None: dbname = "rheas" try: pg.connect("dbname={0}".format(dbname)) except: print("Cannot connect to database {0}. Please restart it by running \n {1}/pg_ctl -D {2}/postgres restart".format( dbname, rpath.bins, rpath.data)) sys.exit() # check if database update is requested if db_update: print "Updating database!" update(dbname, config_filename) else: options = config.loadFromFile(config_filename) # check what simulations have been requested if "nowcast" in options: nowcast.execute(dbname, options) if "forecast" in options: forecast.execute(dbname, options)