From 92a657d09895bc1e97195099a8223c0e143259aa Mon Sep 17 00:00:00 2001 From: yasirarism <55983182+yasirarism@users.noreply.github.com> Date: Fri, 24 Feb 2023 17:39:23 +0700 Subject: [PATCH] Add read config.env from url --- misskaty/vars.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/misskaty/vars.py b/misskaty/vars.py index 49f810eb..bdc1578a 100644 --- a/misskaty/vars.py +++ b/misskaty/vars.py @@ -1,12 +1,23 @@ import sys from logging import getLogger from os import environ - from dotenv import load_dotenv -load_dotenv("config.env", override=True) LOGGER = getLogger(__name__) +CONFIG_FILE_URL = environ.get("CONFIG_FILE_URL", "") +if len(CONFIG_FILE_URL) != 0: + try: + res = get(CONFIG_FILE_URL) + if res.status_code == 200: + with open("config.env", "wb+") as f: + f.write(res.content) + else: + logging.error(f"Failed to download config.env {res.status_code}") + except Exception as e: + logging.error(f"CONFIG_FILE_URL: {e}") + +load_dotenv("config.env", override=True) def getConfig(name: str): try: