diff --git a/Dockerfile b/Dockerfile index 23d4cf5..2500655 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,4 @@ RUN pip install pymongo \ dict_hash \ requests -COPY ./ ./ - -RUN chmod 777 /app/configs/sources.json - +COPY ./ ./ \ No newline at end of file diff --git a/configs/config.py b/configs/config.py index 73314c3..9ec72bc 100644 --- a/configs/config.py +++ b/configs/config.py @@ -15,7 +15,8 @@ class AppConfig: username=CONFIGS['db']['username'], password=CONFIGS['db']['password'], authentication_source='admin', - host="mongodb://{host}:27017/{database}".format(host=CONFIGS['db']['host'], database=CONFIGS['db']['name']) + port=27017, + host=CONFIGS['db']['host'] ) def refresh(self): @@ -51,7 +52,7 @@ class AppConfig: new_config = {"sources": {}} for source in r.json(): new_config["sources"][source["source_name"]] = source - + with open("./configs/sources.json", "w") as outfile: outfile.write(json.dumps(new_config)) diff --git a/update.py b/update.py index 5c68fb3..bbe8b44 100644 --- a/update.py +++ b/update.py @@ -35,16 +35,19 @@ class Updater: def do_action(self): print("Start Updater"); - if self.args.config: - print("Start Configure") - self.update_config() - - if not self.is_source_exists(self.args.source): - print("This source not exists, list of sources: " + ', '.join(config.get_sources_list())) + print("Start Configure") + self.update_config() + if hasattr(self.args, 'source') and self.is_source_exists(self.args.source): + print("Start single source" + self.args.source) + self.parse_source(self.args.source) return - print("Start source update") - self.parse_source(self.args.source) + for source in config.get_sources_list(): + try: + print("Start source update" + source) + self.parse_source(source) + except: + print(source + " has error") updater = Updater()