ConfigManager.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import configparser
  2. import os
  3. from pathlib import Path
  4. class ConfigManager(object):
  5. def __init__(self):
  6. # 获取环境变量 ROV_OFFLINE_ENV
  7. env = os.environ.get('ROV_OFFLINE_ENV')
  8. print(f"当前环境: {env}")
  9. project_home = Path(__file__).parent.parent.absolute()
  10. print(f"当前项目目录为: {project_home}")
  11. self.env = env
  12. self.project_home = project_home
  13. if env == "pro":
  14. self.config_file = f"{project_home}/config/config.ini"
  15. else:
  16. self.config_file = f"{project_home}/config/config_test.ini"
  17. self.config = configparser.ConfigParser()
  18. self.config.read(self.config_file)
  19. def get_env(self):
  20. return self.env if self.env is not None else "test"
  21. def get_algorithm_redis_info(self):
  22. return (
  23. self.config.get("algorithm.redis", "host"),
  24. self.config.get("algorithm.redis", "port"),
  25. self.config.get("algorithm.redis", "password")
  26. )
  27. def get_model_inform_feishu_webhook(self):
  28. return self.config.get("feishu", "model.webhook")
  29. def get_vov_model_inform_feishu_webhook(self):
  30. return self.config.get("feishu", "vov.model.webhook")