mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-06-14 22:18:02 +08:00
修复非str环境变量不起作用的bug
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -161,4 +161,5 @@ cython_debug/
|
||||
|
||||
# Custom
|
||||
/auto_bangumi/const_dev.py
|
||||
/config/bangumi.json
|
||||
/config/bangumi.json
|
||||
/auto_bangumi/tester.py
|
||||
|
||||
@@ -7,6 +7,8 @@ ADD requirements.txt .
|
||||
|
||||
RUN pip install -r requirements.txt
|
||||
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
ADD ./auto_bangumi /auto_bangumi
|
||||
ADD ./config /config
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from conf import settings
|
||||
from argument_parser import parse
|
||||
from log import setup_logger
|
||||
from utils import json_config
|
||||
from env_bool import init_switch
|
||||
|
||||
from core.rss_collector import RSSCollector
|
||||
from core.download_client import DownloadClient
|
||||
@@ -41,6 +42,7 @@ def run():
|
||||
logger.debug("Please copy `const_dev.py` to `const_dev.py` to use custom settings")
|
||||
settings.init(DEV_SETTINGS)
|
||||
else:
|
||||
init_switch()
|
||||
settings.init()
|
||||
setup_logger()
|
||||
download_client = DownloadClient()
|
||||
|
||||
@@ -22,21 +22,18 @@ DEFAULT_SETTINGS = {
|
||||
|
||||
ENV_TO_ATTR = {
|
||||
"AB_DOWNLOADER_HOST": "host_ip",
|
||||
"AB_INTERVAL_TIME": ("sleep_time", lambda e: float(e)),
|
||||
"AB_INTERVAL_TIME": "sleep_time",
|
||||
"AB_DOWNLOADER_USERNAME": "user_name",
|
||||
"AB_DOWNLOADER_PASSWORD": "password",
|
||||
"AB_RSS": "rss_link",
|
||||
"AB_DOWNLOAD_PATH": "download_path",
|
||||
"AB_METHOD": "method",
|
||||
"AB_GROUP_TAG": ("enable_group_tag", lambda e: e.lower() in ("true", "1", "t")),
|
||||
"AB_GROUP_TAG": "enable_group_tag",
|
||||
"AB_NOT_CONTAIN": "not_contain",
|
||||
"AB_RULE_DEBUG": ("get_rule_debug", lambda e: e.lower() in ("true", "1", "t")),
|
||||
"AB_DEBUG_MODE": ("debug_mode", lambda e: e.lower() in ("true", "1", "t")),
|
||||
"AB_EP_COMPLETE": (
|
||||
"enable_eps_complete",
|
||||
lambda e: e.lower() in ("true", "1", "t")
|
||||
),
|
||||
"AB_SEASON_ONE": ("season_one_tag", lambda e: e.lower() in ("true", "1", "t"))
|
||||
"AB_RULE_DEBUG": "get_rule_debug",
|
||||
"AB_DEBUG_MODE": "debug_mode",
|
||||
"AB_EP_COMPLETE": "enable_eps_complete",
|
||||
"AB_SEASON_ONE": "season_one_tag"
|
||||
}
|
||||
|
||||
FULL_SEASON_SUPPORT_GROUP = ["Lilith-Raws"]
|
||||
|
||||
23
auto_bangumi/env_bool.py
Normal file
23
auto_bangumi/env_bool.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from conf import settings
|
||||
|
||||
bool_group = [
|
||||
settings.enable_group_tag,
|
||||
settings.get_rule_debug,
|
||||
settings.debug_mode,
|
||||
settings.enable_eps_complete,
|
||||
settings.season_one_tag
|
||||
]
|
||||
|
||||
|
||||
def init_switch():
|
||||
if settings.sleep_time is str:
|
||||
settings.sleep_time = float(settings.sleep_time)
|
||||
for switch in bool_group:
|
||||
if switch is str:
|
||||
switch = switch.lower() in ("true", "t", "i")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
settings.init()
|
||||
settings.sleep_time = float(settings.sleep_time)
|
||||
print(type(settings.sleep_time))
|
||||
Reference in New Issue
Block a user