forked from kuafuai/DevOpsGPT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.py
55 lines (51 loc) · 2.58 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
import yaml
def read_config(key):
try:
file_path = "env.yaml"
with open(file_path, 'r', encoding='utf-8') as file:
config = yaml.safe_load(file)
value = config.get(key)
except Exception as e:
print(f"\033[91mError: Failed to read the {key} configuration, please copy a new env.yaml from env.yaml.tpl and reconfigure it according to the documentation. 读取配置错误,请重新从 env.yaml.tpl 复制一个 env.yaml 进行配置后重启程序。\033[0m")
input("Press Enter to exit...")
exit()
if value is None:
print(f"\033[91mError: Failed to read the {key} configuration, please copy a new env.yaml from env.yaml.tpl and reconfigure it according to the documentation. 读取配置错误,请重新从 env.yaml.tpl 复制一个 env.yaml 进行配置后重启程序。\033[0m")
input("Press Enter to exit...")
exit()
return value
REQUIREMENT_STATUS_NotStarted = "NotStarted"
REQUIREMENT_STATUS_InProgress = "InProgress"
REQUIREMENT_STATUS_Completed = "Completed"
REQUIREMENT_STATUS_Evaluated = "Evaluated"
REQUIREMENT_STATUS_Canceled = "Canceled"
try:
BACKEND_HOST = read_config("BACKEND_HOST")
BACKEND_DEBUG = read_config("BACKEND_DEBUG")
LANGUAGE = read_config("LANGUAGE")
BACKEND_PORT = read_config("BACKEND_PORT")
APP_SECRET_KEY = read_config("APP_SECRET_KEY")
WORKSPACE_PATH = read_config("WORKSPACE_PATH")
AICODER_ALLOWED_ORIGIN = read_config("AICODER_ALLOWED_ORIGIN")
SQLALCHEMY_DATABASE_URI = read_config("SQLALCHEMY_DATABASE_URI")
GPT_KEYS = json.loads(read_config("GPT_KEYS"))
LLM_MODEL = read_config("LLM_MODEL")
MODE = read_config("MODE")
GRADE = read_config("GRADE")
AUTO_LOGIN = read_config("AUTO_LOGIN")
USERS = json.loads(read_config("USERS"))
DEVOPS_TOOLS = read_config("DEVOPS_TOOLS")
GIT_ENABLED = read_config("GIT_ENABLED")
GIT_URL = read_config("GIT_URL")
GIT_API = read_config("GIT_API")
GIT_TOKEN = read_config("GIT_TOKEN")
GIT_USERNAME = read_config("GIT_USERNAME")
GIT_EMAIL = read_config("GIT_EMAIL")
CD_TOOLS = read_config("CD_TOOLS")
CD_ACCESS_KEY = read_config("CD_ACCESS_KEY")
CD_SECRET_KEY = read_config("CD_SECRET_KEY")
except Exception as e:
print(f"\033[91mError: Failed to read the configuration, please copy a new env.yaml from env.yaml.tpl and reconfigure it according to the documentation. Error in env.yaml: {str(e)}. 读取配置错误,请重新从 env.yaml.tpl 复制一个 env.yaml 进行配置后重启程序。 \033[0m")
input("Press Enter to exit...")
exit()