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

Method install

class/projectModel/btpyvm.py:290–322  ·  view source on GitHub ↗
(self, base_url, extended_args='')

Source from the content-addressed store, hash-verified

288 p.wait()
289
290 def install(self, base_url, extended_args='') -> Tuple[bool, str]:
291 print("开始安装......", file=_vm_std.out, flush=True)
292 if not self.is_pypy:
293 dst = os.path.join(self.bt_python_path, self.version)
294 else:
295 dst = os.path.join(self.bt_pypy_path, self.version)
296 if os.path.isdir(dst):
297 return True, "已安装"
298 # 下载文件
299 if not self.download(base_url):
300 return False, "文件下载并验证失败!"
301 # 安装python
302 if not self._install(extended_args):
303 return False, "解压安装失败!"
304 print("安装完成!", file=_vm_std.out, flush=True)
305 home_path = self.bt_python_path + "/" + self.version
306 if self.is_pypy:
307 home_path = self.bt_pypy_path + "/" + self.version
308
309 bin_path = "{}/bin/python".format(home_path)
310 if not os.path.exists(bin_path):
311 bin_path = "{}/bin/python3".format(home_path)
312 if not os.path.exists(bin_path):
313 print("python安装失败!")
314 return False, "python安装失败!"
315
316 if bin_path == "{}/bin/python3".format(home_path):
317 os.symlink(os.path.realpath(bin_path), "{}/bin/python".format(home_path))
318 elif bin_path == "{}/bin/python".format(home_path) and not os.path.exists("{}/bin/python3".format(home_path)):
319 os.symlink(os.path.realpath(bin_path), "{}/bin/python3".format(home_path))
320
321 EnvironmentManager.add_python_env("system", bin_path)
322 return True, ""
323
324 @staticmethod
325 def parse_version(version: str) -> Tuple[bool, str]:

Callers 2

api_installMethod · 0.45
cmd_installMethod · 0.45

Calls 6

downloadMethod · 0.95
_installMethod · 0.95
add_python_envMethod · 0.80
joinMethod · 0.45
formatMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected