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

Method group_info

mod/project/java/groupMod.py:343–410  ·  view source on GitHub ↗
(self, project_cache: Optional[dict] = None)

Source from the content-addressed store, hash-verified

341 return ("start", "stop"), ""
342
343 def group_info(self, project_cache: Optional[dict] = None) -> Optional[dict]:
344 if not self.config:
345 return
346 if not project_cache:
347 project_ids = [i["id"] for i in self.config["projects"]]
348 if not project_ids:
349 data = copy.deepcopy(self.config)
350 data["group_id"] = self.group_id
351 return data
352
353 projects = public.M('sites').where(
354 'project_type=? and id IN ({})'.format(",".join(["?"] * len(project_ids))),
355 ('Java', *project_ids)).select()
356 project_cache = {}
357 for i in projects:
358 i["project_config"] = json.loads(i["project_config"])
359 project_cache[i["id"]] = i
360
361 j_pro = JavaProject()
362
363 res = copy.deepcopy(self.config)
364 res["group_id"] = self.group_id
365 res["operation_info"], res["now_operation"] = self.get_operation_info()
366 running_num = 0
367 need_del = []
368 for idx, i in enumerate(res["projects"]):
369 if i["id"] in project_cache:
370 try:
371 listen = []
372 pid = j_pro.get_project_pid(project_cache[i["id"]])
373 p = psutil.Process(int(pid))
374 connections = p.connections()
375 for connection in connections:
376 if connection.status == "LISTEN":
377 listen.append(connection.laddr.port)
378 except:
379 i["running"] = False
380 i["project_status"] = 'not_run'
381 i["pid"] = None
382 i["listen"] = []
383 continue
384
385 running_num += 1
386 i["running"] = True
387 i["project_status"] = self.do_check_info(i["check_info"], p)
388 i["pid"] = p.pid
389 i["listen"] = listen
390 else:
391 need_del.append(idx)
392
393 for j in need_del[::-1]:
394 del res["projects"][j]
395 del self.config["projects"][j]
396
397 if need_del:
398 self.save_group_data()
399
400 if not res["now_operation"]:

Callers 1

group_infoMethod · 0.95

Calls 11

get_operation_infoMethod · 0.95
do_check_infoMethod · 0.95
save_group_dataMethod · 0.95
get_project_pidMethod · 0.80
selectMethod · 0.45
whereMethod · 0.45
MMethod · 0.45
formatMethod · 0.45
joinMethod · 0.45
loadsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected