Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

35 rindas
724B

  1. # encoding:utf-8
  2. import json
  3. import os
  4. from common.log import logger
  5. config = {}
  6. md5 = None
  7. def load_config():
  8. global config
  9. config_path = "./config.json"
  10. if not os.path.exists(config_path):
  11. raise Exception('配置文件不存在,请根据config-template.json模板创建config.json文件')
  12. config_str = read_file(config_path)
  13. # 将json字符串反序列化为dict类型
  14. config = json.loads(config_str)
  15. logger.info("[INIT] load config: {}".format(config))
  16. return config
  17. def get_root():
  18. return os.path.dirname(os.path.abspath( __file__ ))
  19. def read_file(path):
  20. with open(path, mode='r', encoding='utf-8') as f:
  21. return f.read()
  22. def conf():
  23. return config