宝塔面板添加Python项目安装python环境失败
2025-12-29 20:33 morefun
https://github.com/aaPanel/BaoTa/blob/main/class/projectModel/btpyvm.py
/www/server/panel/class/projectModel/btpyvm.py
顶部导入
bs4 from bs4 import BeautifulSoup
替换解析代码
def __parser_xml(self, data_txt: str) -> List[PythonVersion]:
res_list = []
# data_txt = data_txt.replace("<hr>", "")
last_2 = {
"data": (2, 0, 0),
"version": None,
}
# root = cElementTree.fromstring(data_txt)
# for data in root.findall("./body/pre/a"):
# v_str = data.text
# if v_str.startswith("2."):
# ver = v_str.strip("/")
# t_version = parse_version_to_list(ver)
# if t_version > last_2["data"]:
# last_2["data"] = t_version
# last_2["version"] = ver
# continue
# if v_str.startswith("3."):
# p_v = PythonVersion(v_str.strip("/"))
# res_list.append(p_v)
# continue
soup = BeautifulSoup(data_txt, 'html.parser')
links = soup.find_all('a')
for link in links:
v_str = link.text
if v_str.startswith("2."):
ver = v_str.strip("/")
t_version = parse_version_to_list(ver)
if t_version > last_2["data"]:
last_2["data"] = t_version
last_2["version"] = ver
continue
elif v_str.startswith("3."):
p_v = PythonVersion(v_str.strip("/"))
res_list.append(p_v)
continue
if last_2["version"]:
res_list.insert(0, PythonVersion(last_2["version"]))
res_list.sort(key=lambda x: x.ver_t)
need_remove = []
for ver in res_list[::-1]:
if not self.test_last_version_is_stable(ver):
need_remove.append(ver)
else:
break
for ver in need_remove:
res_list.remove(ver)
return res_list
插件
[该文章已设置加密,请点击标题输入密码访问]
【逻辑买卖】实战课程视频资料
【逻辑买卖】实战课程视频资料总共有10节
【逻辑买卖】第一课:https://weixin.qq.com/sph/AoQGziPhC
【逻辑买卖】第二课:https://weixin.qq.com/sph/AwjsDwygW
【逻辑买卖】第三课:https://weixin.qq.com/sph/AmU5fkDcz
【逻辑买卖】第四课:https://weixin.qq.com/sph/AzLURU9er
【逻辑买卖】第五课:https://weixin.qq.com/sph/AnH81gtDr
【逻辑买卖】第五课:https://sgdl.shgsec.com/gnN9R
【逻辑买卖】第六课:https://sgdl.shgsec.com/4YmpLn
【逻辑买卖】第七课:https://sgdl.shgsec.com/4eubkl
【逻辑买卖】第八课:https://sgdl.shgsec.com/1D660m
【逻辑买卖】第九课:https://sgdl.shgsec.com/C4iyu
【逻辑买卖】第十课:https://sgdl.shgsec.com/EhCww
标签: 逻辑买卖