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

Method update_report

mod/project/python/pyenv_tool.py:1056–1084  ·  view source on GitHub ↗
(cls, *now_report: Dict)

Source from the content-addressed store, hash-verified

1054
1055 @classmethod
1056 def update_report(cls, *now_report: Dict) -> Optional[str]:
1057 try:
1058 with open(cls.REPORT_FILE, "r") as fs:
1059 old_data = json.loads(fs.read())
1060 except:
1061 old_data = {"environments": [], "update_time": int(time.time())}
1062
1063 path_map = OrderedDict()
1064 for e in old_data["environments"]:
1065 path_map[e["bin_path"]] = e
1066
1067 add_list = []
1068 for e in now_report:
1069 if e["bin_path"] in path_map:
1070 tmp_ps = path_map[e["bin_path"]]["ps"]
1071 path_map[e["bin_path"]].update(e)
1072 if tmp_ps and not path_map[e["bin_path"]]["ps"]:
1073 path_map[e["bin_path"]]["ps"] = tmp_ps
1074 else:
1075 path_map[e["bin_path"]] = e
1076 add_list.append(e)
1077
1078 now_data = {"environments": add_list + old_data["environments"], "update_time": int(time.time())}
1079 try:
1080 with open(cls.REPORT_FILE, "w") as fs:
1081 fs.write(json.dumps(now_data, indent=4))
1082 return None
1083 except Exception as e:
1084 return "保存记录失败:{}".format(e)
1085
1086 def init_report(self):
1087 if os.path.exists(self.REPORT_FILE):

Callers 5

create_venvMethod · 0.95
create_venv_syncMethod · 0.95
init_reportMethod · 0.95
add_python_envMethod · 0.95
set_python_env_psMethod · 0.80

Calls 9

openFunction · 0.85
timeMethod · 0.80
loadsMethod · 0.45
readMethod · 0.45
updateMethod · 0.45
appendMethod · 0.45
writeMethod · 0.45
dumpsMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected