mirror of
https://github.com/yasirarism/MissKatyPyro.git
synced 2025-12-29 17:44:50 +00:00
Fix updater
This commit is contained in:
parent
30f151a565
commit
f62bd5fa53
2 changed files with 20 additions and 20 deletions
|
|
@ -1,28 +1,9 @@
|
|||
import sys, requests
|
||||
from logging import getLogger
|
||||
from os import environ
|
||||
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]
|
||||
|
|
|
|||
21
update.py
21
update.py
|
|
@ -1,8 +1,27 @@
|
|||
from subprocess import run as srun
|
||||
import logging, os
|
||||
import logging, os, requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
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
|
||||
|
||||
load_dotenv("config.env", override=True)
|
||||
|
||||
UPSTREAM_REPO_URL = os.environ.get("UPSTREAM_REPO_URL", "")
|
||||
if len(UPSTREAM_REPO_URL) == 0:
|
||||
UPSTREAM_REPO_URL = None
|
||||
|
|
|
|||
Loading…
Reference in a new issue