load.py 994 B

1234567891011121314151617181920212223242526272829303132333435
  1. import sys
  2. from pathlib import Path
  3. import yaml
  4. __all__ = [
  5. 'mongo_conf', 'redis_conf', 'oss_conf', 'es_conf',
  6. 'constants',
  7. 'headers', 'jy_proxy', 'node_module',
  8. 'analyze_url', 'node_module_path'
  9. ]
  10. base_path = Path(__file__).parent
  11. yaml_conf = (base_path / 'conf.yaml').resolve()
  12. yaml_constants = (base_path / 'constants.yaml').resolve()
  13. with open(yaml_conf, encoding="utf-8") as f:
  14. conf = yaml.safe_load(f)
  15. mongo_conf = conf['mongo']
  16. redis_conf = conf['redis']
  17. es_conf: dict = conf['es']
  18. oss_conf: dict = conf['ali_oss']
  19. with open(yaml_constants, encoding="utf-8") as fp:
  20. constants = yaml.safe_load(fp)
  21. headers: dict = constants['headers']
  22. jy_proxy: dict = constants['proxy']
  23. node_module: dict = constants['node_module']
  24. analyze_url = f'http://{es_conf["host"]}:{es_conf["port"]}/{es_conf["db"]}/_analyze'
  25. if sys.platform == 'linux':
  26. node_module_path = node_module['linux']
  27. else:
  28. node_module_path = node_module['windows']