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

Class Group

mod/project/java/groupMod.py:19–711  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19class Group:
20 GROUP_DATA_DIR = "/www/server/panel/data/java_group"
21 GROUP_TMP_DIR = "/var/tmp/springboot/group"
22
23 def __init__(self, group_id: Optional[str] = None, group_data: Optional[dict] = None):
24 self.group_id = group_id
25 if isinstance(group_data, dict):
26 self.config: Optional[Dict[str, Union[str, List]]] = group_data
27 else:
28 self.config = self.load_group_data_by_id()
29
30 if not os.path.exists(self.GROUP_DATA_DIR):
31 os.makedirs(self.GROUP_DATA_DIR, 0o600)
32
33 if not os.path.exists(self.GROUP_TMP_DIR):
34 os.makedirs(self.GROUP_TMP_DIR)
35
36 self.running_data = {
37 "length": 0, # 已完成的数量
38 "remaining": 0, # 未完成的数量
39 "executing": 0, # 正在执行的数量
40 "projects": [], # 项目操作详情
41 "msg": "", # 信息
42 "status": True,
43 }
44
45 # 如果有配置文件,则表示可以执行
46 def can_running(self) -> bool:
47 return isinstance(self.config, dict)
48
49 @staticmethod
50 def new_group_id() -> str:
51 from uuid import uuid4
52 return uuid4().hex[::2]
53
54 # 从配置文件中加载数据
55 def load_group_data_by_id(self) -> Optional[dict]:
56 config_file = "{}/{}.json".format(self.GROUP_DATA_DIR, self.group_id)
57 try:
58 data = json.loads(public.readFile(config_file))
59 except:
60 return None
61 if isinstance(data, dict):
62 return data
63 else:
64 return None
65
66 def save_group_data(self):
67 if self.config:
68 config_file = "{}/{}.json".format(self.GROUP_DATA_DIR, self.group_id)
69 public.writeFile(config_file, json.dumps(self.config))
70
71 # 更新旧版数据
72 @classmethod
73 def update_group_data(cls) -> None:
74 json_file = "/www/server/panel/class/projectModel/java_project_groups.json"
75 if not os.path.isfile(json_file):
76 return

Callers 15

start_groupFunction · 0.90
stop_groupFunction · 0.90
group_listMethod · 0.70
add_groupMethod · 0.70
add_project_to_groupMethod · 0.70
add_projects_to_groupMethod · 0.70
modify_groupMethod · 0.70
modify_group_projectsMethod · 0.70
modify_group_projectMethod · 0.70
change_sort_typeMethod · 0.70
group_infoMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected