def main(): logger.info('Started Cron') startTime = time.time() print(str(datetime.datetime.now())) try: if RUN_GLOFAS: storeHistoric() for fcStep, days in LEAD_TIMES.items(): fc = Forecast(fcStep, days) if RUN_GLOFAS: fc.glofasData.process() if RUN_RAINFALL: fc.rainfallData.process() if CALCULATE_EXTENT: fc.floodExtent.calculate() if CALCULATE_EXTENT and CALCULATE_EXPOSURE: fc.floodExtent.callAllExposure() fc.db.upload() fc.db.processDynamicDataDb() notify() except Exception as e: # If a fatal exception occurs during the cronjob # logs full stack trace and sends email logger.exception("Fatal error occured during the process") traceback.print_exc() elapsedTime = str(time.time() - startTime) print(elapsedTime) logger.info('Finished Cron in seconds %s', elapsedTime)
def main(): logger.info('Started Test') startTime = time.time() print(str(datetime.datetime.now())) try: for leadTimeLabel, leadTimeValue in LEAD_TIMES.items(): fc = Forecast(leadTimeLabel, leadTimeValue) fc.rainfallData.process() except Exception as e: # If a fatal exception occurs during the cronjob # logs full stack trace and sends email logger.exception("Fatal error occured during the process") traceback.print_exc() elapsedTime = str(time.time() - startTime) print(elapsedTime) logger.info('Finished Test in seconds %s', elapsedTime)
def main(): logger.info("Started Cron") startTime = time.time() print(str(datetime.datetime.now())) try: storeHistoric() for COUNTRY_CODE in COUNTRY_CODES: print('--------STARTING: ' + COUNTRY_CODE + '--------------------------') COUNTRY_SETTINGS = SETTINGS[COUNTRY_CODE] LEAD_TIMES = COUNTRY_SETTINGS['lead_times'] RUN_GLOFAS = COUNTRY_SETTINGS['models']['glofas'] RUN_RAINFALL = COUNTRY_SETTINGS['models']['rainfall'] for fcStep, days in LEAD_TIMES.items(): print('--------STARTING: ' + fcStep + '--------------------------') fc = Forecast(fcStep, days, COUNTRY_CODE) if RUN_GLOFAS: fc.glofasData.process() if RUN_RAINFALL: fc.rainfallData.process() if CALCULATE_EXTENT: fc.floodExtent.calculate() if CALCULATE_EXTENT and CALCULATE_EXPOSURE: fc.floodExtent.callAllExposure() fc.db.upload() fc.db.processDynamicDataDb() notify(COUNTRY_CODE) except Exception as e: # If a fatal exception occurs during the cronjob # logs full stack trace and sends email logger.exception("Fatal error occured during the process") traceback.print_exc() elapsedTime = str(time.time() - startTime) print(elapsedTime) logger.info("Finished Cron in seconds %s", elapsedTime)
def main(): logger.info("Started Cron") startTime = time.time() print(str(datetime.datetime.now())) try: for COUNTRY_CODE in COUNTRY_CODES: print('--------STARTING: ' + COUNTRY_CODE + '--------------------------') COUNTRY_SETTINGS = SETTINGS[COUNTRY_CODE] LEAD_TIMES = COUNTRY_SETTINGS['lead_times'] for leadTimeLabel, leadTimeValue in LEAD_TIMES.items(): print('--------STARTING: ' + leadTimeLabel + '--------------------------') fc = Forecast(leadTimeLabel, leadTimeValue, COUNTRY_CODE, COUNTRY_SETTINGS['model']) if COUNTRY_SETTINGS['model'] == 'rainfall': fc.rainfallData.process() if COUNTRY_SETTINGS['model'] == 'glofas': fc.glofasData.process() fc.floodExtent.calculate() fc.exposure.callAllExposure() fc.db.upload() fc.db.processDynamicDataDb() notify(COUNTRY_CODE) except Exception as e: # If a fatal exception occurs during the cronjob # logs full stack trace and sends email logger.exception("Fatal error occured during the process") traceback.print_exc() elapsedTime = str(time.time() - startTime) print(elapsedTime) logger.info("Finished Cron in seconds %s", elapsedTime)