From 16f2bd4611e45670aa53ebca869258eda059daff Mon Sep 17 00:00:00 2001 From: zqc <835569504@qq.com> Date: Fri, 27 Feb 2026 13:41:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/contants.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 common/contants.py diff --git a/common/contants.py b/common/contants.py new file mode 100644 index 0000000..6986cdd --- /dev/null +++ b/common/contants.py @@ -0,0 +1,26 @@ + import yaml +from utils.logger import get_logger + +logger = get_logger(__name__) + +ALERT_PUSH_URL = "" + + +def init_config(config_path: str = "config.yaml"): + """ + 从配置文件初始化全局配置 + + Args: + config_path: 配置文件路径,默认为 config.yaml + """ + global ALERT_PUSH_URL + + try: + with open(config_path, "r", encoding="utf-8") as f: + cfg = yaml.safe_load(f) + + ALERT_PUSH_URL = cfg.get("alert_push_url", "") + logger.info(f"[INFO] Config initialized from {config_path}, alert_push_url={ALERT_PUSH_URL}") + + except Exception as e: + logger.error(f"[ERROR] Failed to load config from {config_path}: {e}") \ No newline at end of file