This commit is contained in:
yasir 2023-02-27 12:16:59 +07:00
parent 408283e84e
commit d163ea76a1
2 changed files with 19 additions and 20 deletions

View file

@ -5,6 +5,24 @@ from dotenv import load_dotenv
LOGGER = getLogger(__name__)
CONFIG_FILE_URL = environ.get("CONFIG_FILE_URL", "")
try:
if len(CONFIG_FILE_URL) == 0:
raise TypeError
try:
res = requests.get(CONFIG_FILE_URL)
if res.status_code == 200:
with open("config.env", "wb+") as f:
f.write(res.content)
else:
LOGGER.error(f"config.env err: {res.status_code}")
except Exception as e:
LOGGER.error(f"ENV_URL: {e}")
except:
pass
load_dotenv("config.env", override=True)
def getConfig(name: str):
try:
return environ[name]

View file

@ -1,27 +1,8 @@
import requests
from subprocess import run as srun
import logging, os, dotenv
import logging, os
LOGGER = logging.getLogger(__name__)
CONFIG_FILE_URL = os.environ.get("CONFIG_FILE_URL", "")
try:
if len(CONFIG_FILE_URL) == 0:
raise TypeError
try:
res = requests.get(CONFIG_FILE_URL)
if res.status_code == 200:
with open("config.env", "wb+") as f:
f.write(res.content)
else:
LOGGER.error(f"config.env err: {res.status_code}")
except Exception as e:
LOGGER.error(f"ENV_URL: {e}")
except:
pass
dotenv.load_dotenv("config.env", override=True)
UPSTREAM_REPO = os.environ.get("UPSTREAM_REPO", "")
if len(UPSTREAM_REPO) == 0:
UPSTREAM_REPO = None