12345678910111213141516171819202122232425262728293031323334353637 |
- import configparser
- import os
- from pathlib import Path
- class ConfigManager(object):
- def __init__(self):
- # 获取环境变量 ROV_OFFLINE_ENV
- env = os.environ.get('ROV_OFFLINE_ENV')
- print(f"当前环境: {env}")
- project_home = Path(__file__).parent.parent.absolute()
- print(f"当前项目目录为: {project_home}")
- self.env = env
- self.project_home = project_home
- if env == "pro":
- self.config_file = f"{project_home}/config/config.ini"
- else:
- self.config_file = f"{project_home}/config/config_test.ini"
- self.config = configparser.ConfigParser()
- self.config.read(self.config_file)
- def get_env(self):
- return self.env if self.env is not None else "test"
- def get_algorithm_redis_info(self):
- return (
- self.config.get("algorithm.redis", "host"),
- self.config.get("algorithm.redis", "port"),
- self.config.get("algorithm.redis", "password")
- )
- def get_model_inform_feishu_webhook(self):
- return self.config.get("feishu", "model.webhook")
- def get_vov_model_inform_feishu_webhook(self):
- return self.config.get("feishu", "vov.model.webhook")
|