diff --git a/src/covid19/blueprints/ecdc/ecdc_service_config.py b/src/covid19/blueprints/ecdc/ecdc_service_config.py deleted file mode 100644 index 00610e19e157260c858d60fe7a35b81b4e9c2380..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/ecdc/ecdc_service_config.py +++ /dev/null @@ -1,17 +0,0 @@ -import os - -from covid19.blueprints.ecdc.ecdc_model_import import EcdcImport - - -class EcdcServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'ECDC' - self.sub_category = 'European Centre for Disease Prevention and Control' - self.tablename = EcdcImport.__tablename__ - self.cvsfile_name = "ecdc_europa_data.csv" - self.url_src = "https://opendata.ecdc.europa.eu/covid19/casedistribution/csv/" - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_ok = "downloaded: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/ecdc/ecdc_service_download.py b/src/covid19/blueprints/ecdc/ecdc_service_download.py deleted file mode 100644 index f9f5bb2486d930c3085a9dc43ca971356c2da13f..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/ecdc/ecdc_service_download.py +++ /dev/null @@ -1,49 +0,0 @@ -import os -import wget -from flask import flash -from database import app -from covid19.blueprints.ecdc.ecdc_service_config import EcdcServiceConfig - - -class EcdcServiceDownload: - def __init__(self, database, config: EcdcServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" ECDC Service Download [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" ECDC Service Download [ready] ") - - def download_file(self): - app.logger.info("------------------------------------------------------------") - app.logger.info(" download ECDC [begin]") - app.logger.info("------------------------------------------------------------") - app.logger.info(" download FILE: "+self.cfg.cvsfile_name+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - try: - os.makedirs(self.cfg.data_path, exist_ok=True) - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - wget.download(self.cfg.url_src, self.cfg.cvsfile_path) - app.logger.info("------------------------------------------------------------") - except RuntimeError as runtimeError: - app.logger.error("############################################################") - app.logger.error(" " + runtimeError + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - except AttributeError as attributeError: - app.logger.error("############################################################") - app.logger.error(attributeError) - app.logger.error("############################################################") - flash(message="error after downloading: " + self.cfg.cvsfile_path, category='error') - except Exception as exception: - app.logger.error("############################################################") - app.logger.error(exception) - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - finally: - app.logger.info(" download ECDC [done]") - msg = "downloaded: " + self.cfg.cvsfile_path+" from " + self.cfg.url_src - flash(msg) - return self diff --git a/src/covid19/blueprints/owid/owid_service_config.py b/src/covid19/blueprints/owid/owid_service_config.py deleted file mode 100644 index 2daf1e12ffe1d9885fe7888f6c94b71661abd716..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/owid/owid_service_config.py +++ /dev/null @@ -1,17 +0,0 @@ -import os - -from covid19.blueprints.owid.owid_model_import import OwidImport - - -class OwidServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'OWID' - self.sub_category = 'Our World in Data' - self.tablename = OwidImport.__tablename__ - self.cvsfile_name = "owid-covid-data.csv" - self.url_src = "https://covid.ourworldindata.org/data/owid-covid-data.csv" - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_ok = "downloaded: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/owid/owid_service_download.py b/src/covid19/blueprints/owid/owid_service_download.py deleted file mode 100644 index f07d7483dc272fc281f6621d4deee5661b637762..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/owid/owid_service_download.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import wget -import subprocess -from flask import flash -from database import app -from covid19.blueprints.owid.owid_service_config import OwidServiceConfig - - -class OwidServiceDownload: - def __init__(self, database, config: OwidServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" OWID Service Download [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" OWID Service Download [ready]") - - def __download_with_subprocess_and_os_native_wget(self): - orig_workdir = os.getcwd() - os.chdir(self.cfg.data_path) - my_cmd = ['wget ' + self.cfg.url_src] - subprocess.Popen(my_cmd, shell=True) - os.chdir(orig_workdir) - return self - - def download_file(self): - app.logger.info(" download - [begin] ") - app.logger.info("------------------------------------------------------------") - app.logger.info(" download FILE: "+self.cfg.cvsfile_name+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - try: - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - self.__download_with_subprocess_and_os_native_wget() - #data_file = wget.download(self.cfg.url_src, self.cfg.cvsfile_path) - #app.logger.info(" " + data_file + " ") - except RuntimeError as runtimeError: - app.logger.error("############################################################") - app.logger.error(" " + runtimeError + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - except AttributeError as attributeError: - app.logger.error("############################################################") - app.logger.error(attributeError) - app.logger.error("############################################################") - flash(message="error after downloading: " + self.cfg.cvsfile_path, category='error') - except Exception as exception: - app.logger.error("############################################################") - app.logger.error(exception) - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - finally: - app.logger.info("------------------------------------------------------------") - app.logger.info(" download - [done] ") - msg = "downloaded: " + self.cfg.cvsfile_path+" from "+self.cfg.url_src - flash(msg) - return self - diff --git a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_config.py b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_config.py deleted file mode 100644 index 89a98de3f6039966e5de0fefe4d51e49188fbc1c..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_config.py +++ /dev/null @@ -1,17 +0,0 @@ -from datetime import date -import os -from covid19.blueprints.rki_bundeslaender.rki_bundeslaender_model_import import RkiBundeslaenderImport - - -class RkiBundeslaenderServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'RKI' - self.sub_category = 'Bundeslaender' - self.tablename = RkiBundeslaenderImport.__tablename__ - self.url_src = "https://opendata.arcgis.com/datasets/ef4b445a53c1406892257fe63129a8ea_0.csv" - self.cvsfile_name = "RKI_COVID19__" + date.today().isoformat() + "__bundeslaender.csv" - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_ok = "downloaded: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_download.py b/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_download.py deleted file mode 100644 index a11630a455aef27e7b085fd9a6cda3af6e627af2..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_bundeslaender/rki_bundeslaender_service_download.py +++ /dev/null @@ -1,52 +0,0 @@ -import os -import wget -from flask import flash - -from database import app -from covid19.blueprints.rki_bundeslaender.rki_bundeslaender_service_config import RkiBundeslaenderServiceConfig - - -class RkiBundeslaenderServiceDownload: - def __init__(self, database, config: RkiBundeslaenderServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" RKI Service Download [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" RKI Service Download [ready]") - - def download_file(self): - app.logger.info(" download - RKI [begin] ") - app.logger.info("------------------------------------------------------------") - app.logger.info(" download FILE: "+self.cfg.cvsfile_path+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - try: - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - data_file = wget.download(self.cfg.url_src, self.cfg.cvsfile_path) - app.logger.info("download success: " + data_file + " ") - except RuntimeError as runtimeError: - app.logger.error("############################################################") - app.logger.error(" " + runtimeError + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - except AttributeError as attributeError: - app.logger.error("############################################################") - app.logger.error(attributeError) - app.logger.error("############################################################") - flash(message="error after downloading: " + self.cfg.cvsfile_path, category='error') - except Exception as exception: - app.logger.error("############################################################") - app.logger.error(exception) - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - finally: - app.logger.info("") - app.logger.info("------------------------------------------------------------") - app.logger.info(" downloaded FILE: "+self.cfg.cvsfile_path+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - app.logger.info(" download - RKI [done] ") - msg = "downloaded: " + self.cfg.cvsfile_path+" from "+self.cfg.url_src - flash(msg) - return self diff --git a/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_config.py b/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_config.py deleted file mode 100644 index 91a2b34c34644e576d3389b635f2c1eb43ced013..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_config.py +++ /dev/null @@ -1,18 +0,0 @@ -from datetime import date -import os - -from covid19.blueprints.rki_landkreise.rki_landkreise_model_import import RkiLandkreiseImport - - -class RkiLandkreiseServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'RKI' - self.sub_category = 'Landkreise' - self.tablename = RkiLandkreiseImport.__tablename__ - self.url_src = "https://opendata.arcgis.com/datasets/917fc37a709542548cc3be077a786c17_0.csv" - self.cvsfile_name = "RKI_COVID19__" + date.today().isoformat() + "__landkreise.csv" - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_ok = "downloaded: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_download.py b/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_download.py deleted file mode 100644 index 939b3e2235fe02fba751bc075e5ea97ab2abaa9c..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_landkreise/rki_landkreise_service_download.py +++ /dev/null @@ -1,50 +0,0 @@ -import os -import wget -from flask import flash - -from database import app -from covid19.blueprints.rki_landkreise.rki_landkreise_service_config import RkiLandkreiseServiceConfig - - -class RkiLandkreiseServiceDownload: - def __init__(self, database, config: RkiLandkreiseServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" RKI Landkreise Service Download [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" RKI Landkreise Service Download [ready]") - - def download_file(self): - app.logger.info(" RKI Landkreise Service Download - download_file begin] ") - app.logger.info("------------------------------------------------------------") - app.logger.info(" download FILE: "+self.cfg.cvsfile_name+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - try: - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - data_file = wget.download(self.cfg.url_src, self.cfg.cvsfile_path) - app.logger.info(" " + data_file + " ") - except RuntimeError as runtimeError: - app.logger.error("############################################################") - app.logger.error(" runtimeError " + runtimeError + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - except AttributeError as attributeError: - app.logger.error("############################################################") - app.logger.error(" attributeError " + attributeError + " ") - app.logger.error("############################################################") - flash(message="error after downloading: " + self.cfg.cvsfile_path, category='error') - except Exception as exception: - app.logger.error("############################################################") - app.logger.error(" exception " + exception + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - finally: - app.logger.info("------------------------------------------------------------") - app.logger.info(" RKI Landkreise Service Download - download_file [done] ") - msg = "downloaded: " + self.cfg.cvsfile_path+" from "+self.cfg.url_src - flash(msg) - return self - diff --git a/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_config.py b/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_config.py deleted file mode 100644 index 403690677f1a6a5764eb64f08f112b7ebd950b18..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_config.py +++ /dev/null @@ -1,18 +0,0 @@ -import os - -from covid19.blueprints.rki_vaccination.rki_vaccination_model_import import RkiVaccinationImport - - -class RkiVaccinationServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'RKI' - self.sub_category = 'Vaccination' - self.tablename = RkiVaccinationImport.__tablename__ - self.url_src = "https://impfdashboard.de/static/data/germany_vaccinations_timeseries_v2.tsv" - self.cvsfile_name = "germany_vaccinations_timeseries_v2.tsv" - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_job = "download FILE: "+self.cfg.cvsfile_name+" from "+self.cfg.url_src - self.msg_ok = "downloaded FILE: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_download.py b/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_download.py deleted file mode 100644 index 926398646ca93a99785e68a507439655105cb866..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/rki_vaccination/rki_vaccination_service_download.py +++ /dev/null @@ -1,71 +0,0 @@ -import os -import wget -import subprocess -from flask import flash -from database import app -from covid19.blueprints.rki_vaccination.rki_vaccination_service_config import RkiVaccinationServiceConfig - - -class RkiVaccinationServiceDownload: - def __init__(self, database, config: RkiVaccinationServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" "+self.cfg+" Download Service [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" "+self.cfg+" Download Service [ready]") - - def __log_error(self, error_msg: str): - flash_msg = self.cfg.msg_error + error_msg - flash(message=flash_msg, category='error') - app.logger.error("############################################################") - app.logger.error(flash_msg) - app.logger.error("############################################################") - return self - - def __log_success(self, data_file): - app.logger.info(" download success: " + data_file + " ") - app.logger.info(self.cfg.msg_ok) - flash(self.cfg.msg_ok) - return self - - def __prepare_download(self): - os.makedirs(self.cfg.data_path, exist_ok=True) - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - return self - - def __download_with_wget(self, src_url: str, target_file_path: str): - data_file = wget.download(src_url, target_file_path) - self.__log_success(data_file) - return self - - def __download_with_subprocess_and_os_native_wget(self): - orig_workdir = os.getcwd() - os.chdir(self.cfg.data_path) - my_cmd = ['wget ' + self.cfg.url_src] - subprocess.Popen(my_cmd, shell=True) - os.chdir(orig_workdir) - return self - - def download_file(self): - app.logger.info(" download_file - "+self.cfg+" [begin] ") - app.logger.info("------------------------------------------------------------") - app.logger.info(self.cfg.msg_job) - app.logger.info("------------------------------------------------------------") - try: - self.__prepare_download() - self.__download_with_wget(self.cfg.url_src, self.cfg.cvsfile_path) - except RuntimeError as runtimeError: - self.__log_error(" RuntimeError: " + runtimeError + " ") - except OSError as osError: - self.__log_error(" OSError: " + osError + " ") - except AttributeError as attributeError: - self.__log_error(" AttributeError: " + attributeError + " ") - except Exception as exception: - self.__log_error(" Exception: " + exception) - finally: - app.logger.info("------------------------------------------------------------") - app.logger.info(" download_file - "+self.cfg+" [done] ") - return self diff --git a/src/covid19/blueprints/who/who_service_config.py b/src/covid19/blueprints/who/who_service_config.py deleted file mode 100644 index 64461e570781d709045487b10123d0b8fc0147ec..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/who/who_service_config.py +++ /dev/null @@ -1,17 +0,0 @@ -import os - -from covid19.blueprints.who.who_model_import import WhoImport - - -class WhoServiceConfig: - def __init__(self): - self.limit_nr = 20 - self.data_path = ".." + os.sep + ".." + os.sep + "data" - self.category = 'WHO' - self.sub_category = 'Cases and Deaths' - self.tablename = WhoImport.__tablename__ - self.cvsfile_name = "WHO-COVID-19-global-data.csv" - self.url_src = "https://covid19.who.int/" + self.cvsfile_name - self.cvsfile_path = self.data_path + os.sep + self.cvsfile_name - self.msg_ok = "downloaded: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src - self.msg_error = "while downloading: " + self.cfg.cvsfile_path + " from " + self.cfg.url_src diff --git a/src/covid19/blueprints/who/who_service_download.py b/src/covid19/blueprints/who/who_service_download.py deleted file mode 100644 index 137c4f2bc91d17d59277a782da642cc0af090225..0000000000000000000000000000000000000000 --- a/src/covid19/blueprints/who/who_service_download.py +++ /dev/null @@ -1,48 +0,0 @@ -import os -import wget -from flask import flash -from database import app -from covid19.blueprints.who.who_service_config import WhoServiceConfig - - -class WhoServiceDownload: - def __init__(self, database, config: WhoServiceConfig): - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" WHO Service Download [init]") - app.logger.debug("------------------------------------------------------------") - self.__database = database - self.cfg = config - app.logger.debug("------------------------------------------------------------") - app.logger.debug(" WHO Service Download [ready]") - - def download_file(self): - app.logger.info(" download - [begin] ") - app.logger.info("------------------------------------------------------------") - app.logger.info(" download FILE: "+self.cfg.cvsfile_name+" from "+self.cfg.url_src) - app.logger.info("------------------------------------------------------------") - try: - if os.path.isfile(self.cfg.cvsfile_path): - os.remove(self.cfg.cvsfile_path) - data_file = wget.download(self.cfg.url_src, self.cfg.cvsfile_path) - app.logger.info(" download success: " + data_file + " ") - flash(self.cfg.msg_ok) - except RuntimeError as runtimeError: - app.logger.error("############################################################") - app.logger.error(" " + runtimeError + " ") - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - except AttributeError as attributeError: - app.logger.error("############################################################") - app.logger.error(attributeError) - app.logger.error("############################################################") - flash(message="error after downloading: " + self.cfg.cvsfile_path, category='error') - except Exception as exception: - app.logger.error("############################################################") - app.logger.error(exception) - app.logger.error("############################################################") - flash(message="error while downloading: " + self.cfg.cvsfile_path, category='error') - finally: - app.logger.info("------------------------------------------------------------") - app.logger.info(" download - [done] ") - return self -