forked from LiveCarta/LiveCartaMeta
refresh configs
This commit is contained in:
@@ -14,7 +14,3 @@ COPY ./ ./
|
||||
|
||||
RUN chmod 777 /app/configs/sources.json
|
||||
|
||||
RUN python update.py --config
|
||||
|
||||
RUN python update.py --source test
|
||||
|
||||
|
||||
@@ -9,16 +9,18 @@ from configs.configs import CONFIGS
|
||||
|
||||
class AppConfig:
|
||||
def __init__(self):
|
||||
self.config = Dynaconf(settings_files=[
|
||||
"/app/configs/main.json",
|
||||
"/app/configs/sources.json"
|
||||
])
|
||||
|
||||
self.refresh()
|
||||
connect(
|
||||
db=CONFIGS['db']['name'],
|
||||
host="mongodb://{host}:27017/{database}".format(host=CONFIGS['db']['host'], database=CONFIGS['db']['name'])
|
||||
)
|
||||
|
||||
def refresh(self):
|
||||
self.config = Dynaconf(settings_files=[
|
||||
"/app/configs/main.json",
|
||||
"/app/configs/sources.json"
|
||||
])
|
||||
|
||||
def get_bulk_insert_limit(self):
|
||||
if not self.config.bulk_limit:
|
||||
return 1
|
||||
@@ -40,6 +42,7 @@ class AppConfig:
|
||||
}
|
||||
r = requests.get(CONFIGS['application_credentials']['api_url'] + "sources", headers=headers)
|
||||
if r.status_code != 200:
|
||||
|
||||
raise Exception('Bad app response')
|
||||
|
||||
new_config = {"sources": {}}
|
||||
@@ -49,4 +52,6 @@ class AppConfig:
|
||||
with open("./configs/sources.json", "w") as outfile:
|
||||
outfile.write(json.dumps(new_config))
|
||||
|
||||
self.refresh()
|
||||
|
||||
config = AppConfig()
|
||||
@@ -34,7 +34,9 @@ class Updater:
|
||||
config.update_sources()
|
||||
|
||||
def do_action(self):
|
||||
print("Start Updater");
|
||||
if self.args.config:
|
||||
print("Start Configure")
|
||||
self.update_config()
|
||||
return
|
||||
|
||||
@@ -42,6 +44,7 @@ class Updater:
|
||||
print("This source not exists, list of sources: " + ', '.join(config.get_sources_list()))
|
||||
return
|
||||
|
||||
print("Start source update")
|
||||
self.parse_source(self.args.source)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user