22 lines
847 B
Python
22 lines
847 B
Python
import os
|
|
import yaml
|
|
from alg_airport_ffmpeg.common.Constant import ConstantEnum
|
|
|
|
"""
|
|
获取配置项信息
|
|
"""
|
|
|
|
|
|
def get_configs():
|
|
print("开始读取配置文件,获取配置信息:", ConstantEnum.APPLICATION_CONFIG.value[0])
|
|
config_path = os.path.abspath(ConstantEnum.APPLICATION_CONFIG.value[0])
|
|
if not os.path.exists(config_path):
|
|
raise Exception("未找到配置文件:{}".format(ConstantEnum.APPLICATION_CONFIG.value[0]))
|
|
with open(config_path, ConstantEnum.R.value[0], encoding=ConstantEnum.UTF_8.value[0]) as f:
|
|
file_content = f.read()
|
|
content = yaml.load(file_content, yaml.FullLoader)
|
|
if not content:
|
|
raise Exception("配置项不能为空:{}".format(ConstantEnum.APPLICATION_CONFIG.value[0]))
|
|
print("读取配置文件完成!")
|
|
return content
|