MCPcopy Create free account
hub / github.com/aaPanel/BaoTa / check_group_data

Method check_group_data

mod/project/java/groupMod.py:124–194  ·  view source on GitHub ↗

一个组的格式 group = { "group_name": "aaa", "projects": [ { "id": 84, "name": "tduck-api", "level": 1, "check_info": { "type": ("port" or "active

(self)

Source from the content-addressed store, hash-verified

122
123 # 检查数据
124 def check_group_data(self) -> Optional[str]:
125 """
126 一个组的格式
127 group = {
128 "group_name": "aaa",
129 "projects": [
130 {
131 "id": 84,
132 "name": "tduck-api",
133 "level": 1,
134 "check_info": {
135 "type": ("port" or "active"),
136 "port": [8456, 8511],
137 "wait_time": 180,
138 }
139 }
140 ],
141 "sort_type": ("simultaneous" or "sequence")
142 }
143 """
144 # 检查self.config是否为字典
145 if not isinstance(self.config, dict):
146 return "参数格式错误"
147
148 # 检查'sort_type'键是否存在且值为("simultaneous" or "sequence")
149 if "sort_type" not in self.config or self.config["sort_type"] not in ("simultaneous", "sequence"):
150 return "编排方式设置错误"
151
152 if 'group_name' not in self.config or not isinstance(self.config["group_name"], str) \
153 or not self.config["group_name"]:
154 return "分组名称设置错误"
155
156 # 检查projects键是否存在且为列表
157 if "projects" not in self.config or not isinstance(self.config["projects"], list):
158 return "项目列表设置错误"
159
160 # id 不能重复
161 site_id_set = set()
162 # 遍历projects列表中的每个项目
163 for project in self.config["projects"]:
164 # 检查每个项目是否为字典
165 if not isinstance(project, dict):
166 return "项目列表设置错误"
167
168 # 检查'id', 'name', 'level', 'check_info'键是否存在
169 if not all(key in project for key in ("id", "name", "level", "check_info")):
170 return "项目项目配置信息缺失"
171
172 # 检查id、level是否为整数
173 if not isinstance(project["id"], int) or not isinstance(project["level"], int):
174 return "项目id或优先级参数格式错误"
175 else:
176 if project["id"] in site_id_set:
177 return "项目id不能重复"
178 else:
179 site_id_set.add(project["id"])
180
181 # 检查'check_info'是否为字典

Callers 6

add_groupMethod · 0.95
add_project_to_groupMethod · 0.95
add_projects_to_groupMethod · 0.95
modify_groupMethod · 0.95
modify_group_projectsMethod · 0.95
modify_group_projectMethod · 0.95

Calls 3

setFunction · 0.50
addMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected