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

Method get_env_info

class/projectModel/pythonModel.py:3645–3688  ·  view source on GitHub ↗
(self, get)

Source from the content-addressed store, hash-verified

3643 return requirement_dict
3644
3645 def get_env_info(self, get):
3646 force = False
3647 try:
3648 project_name = get.project_name.strip()
3649 if "force" in get:
3650 if isinstance(get.force, str):
3651 if get.force in ("1", "true"):
3652 force = True
3653 else:
3654 force = bool(get.force)
3655 except:
3656 return public.returnMsg(False, "参数错误")
3657
3658 project_info = self.get_project_find(project_name)
3659 if not isinstance(project_info, dict):
3660 return public.returnMsg(False, "没有找到项目")
3661 conf = project_info["project_config"]
3662 pyenv = EnvironmentManager().get_env_py_path(conf.get("python_bin", conf.get("vpath")))
3663 python_version = pyenv.version
3664 requirement_path = conf.get("requirement_path", "")
3665
3666 if requirement_path and os.path.isfile(requirement_path):
3667 requirement_dict = self._read_requirement_file(requirement_path)
3668 else:
3669 requirement_dict = {}
3670
3671 pip_list_data = pyenv.pip_list(force)
3672 pip_list = []
3673 for p, v in pip_list_data:
3674 if p in requirement_dict:
3675 pip_list.append({"name": p, "version": v, "requirement": requirement_dict.pop(p)})
3676
3677 else:
3678 pip_list.append({"name": p, "version": v, "requirement": "--"})
3679
3680 for k, v in requirement_dict.items():
3681 pip_list.append({"name": k, "version": "--", "requirement": v})
3682
3683 return {
3684 "python_version": python_version,
3685 "requirement_path": requirement_path,
3686 "pip_list": pip_list,
3687 "pip_source": self.pip_source_dict
3688 }
3689
3690 def modify_requirement(self, get):
3691 try:

Callers

nothing calls this directly

Calls 10

get_project_findMethod · 0.95
EnvironmentManagerClass · 0.90
returnMsgMethod · 0.80
get_env_py_pathMethod · 0.80
pip_listMethod · 0.80
getMethod · 0.45
appendMethod · 0.45
popMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected