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

Method RemovePythonV

class/projectModel/pythonModel.py:295–316  ·  view source on GitHub ↗

卸载面板安装的Python @author baozi <202-02-22> @param: get ( dict ): 请求信息,包含要删除的版本信息 @return msg : 是否删除成功

(self, get)

Source from the content-addressed store, hash-verified

293 # public.writeFile(path, localtime + "\n" + msg + "\n", "a+")
294
295 def RemovePythonV(self, get):
296 """卸载面板安装的Python
297 @author baozi <202-02-22>
298 @param:
299 get ( dict ): 请求信息,包含要删除的版本信息
300 @return msg : 是否删除成功
301 """
302 v = get.version.split()[0]
303 if "is_pypy" in get and get.is_pypy in ("1", "true", 1, True):
304 path = '{}/pypy_versions'.format(self._pyv_path)
305 else:
306 path = '{}/versions'.format(self._pyv_path)
307 if not os.path.exists(path):
308 return public.returnMsg(True, "卸载Python成功")
309 python_bin = "{}/{}/bin/python".format(path, v)
310 if not os.path.exists(python_bin):
311 python_bin = "{}/{}/bin/python3".format(path, v)
312 if not os.path.exists(python_bin):
313 return public.returnMsg(False, "Python版本不存在")
314
315 res = EnvironmentManager().multi_remove_env(os.path.realpath(python_bin))
316 return res
317
318 def _get_project_conf(self, name_id) -> Union[Dict, bool]:
319 """获取项目的配置信息

Callers

nothing calls this directly

Calls 6

EnvironmentManagerClass · 0.90
returnMsgMethod · 0.80
multi_remove_envMethod · 0.80
splitMethod · 0.45
formatMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected