mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-30 08:50:17 +08:00
删除PROXY_SUPPLEMENT变量,增加只读属性‘PIP_OPTIONS’
1、删除`proxychains4`模块支持,`pip`代理已支持全局模式下的`socks4`、`socks4a`、`socks5`、`socks5h`、`http`、`https`协议; 2、删除`PROXY_SUPPLEMENT`变量,取消手动控制功能; 3、增加自动判断,将`pip`与`update`的代理判断,从手动改为自动,优先级:镜像站 > 全局 > 不代理; 4、将`pip`的附加代理参数,作为只读属性`PIP_OPTIONS`写入到`config`中,其他对象可通过`settings.PIP_OPTIONS`实现快速调用。
This commit is contained in:
@@ -222,52 +222,7 @@ class PluginHelper(metaclass=Singleton):
|
||||
# 插件目录下如有requirements.txt则安装依赖
|
||||
requirements_file = plugin_dir / "requirements.txt"
|
||||
if requirements_file.exists():
|
||||
# 初始化
|
||||
protocol = host = port = username = password = PROXY_CHAINS = PIP_PROXY = ""
|
||||
# 返回json格式解析结果
|
||||
parsed_url = settings.PROXY_URLPARSE()
|
||||
if parsed_url:
|
||||
protocol = parsed_url.get("scheme", "").lower()
|
||||
username = parsed_url.get("username", "")
|
||||
password = parsed_url.get("password", "")
|
||||
host = parsed_url.get("host", "").lower()
|
||||
port = parsed_url.get("port", "")
|
||||
|
||||
# 全局优先,镜像站不存在时,使用全局代理
|
||||
if settings.PROXY_SUPPLEMENT:
|
||||
|
||||
# 检查settings.PROXY_HOST的协议类型,http或https
|
||||
if protocol in {"http", "https"}:
|
||||
if settings.PIP_PROXY:
|
||||
PIP_PROXY = f" -i {settings.PIP_PROXY} " if settings.PIP_PROXY else ""
|
||||
else:
|
||||
# 有主机名与端口号的时候
|
||||
if host and port:
|
||||
PIP_PROXY = f" --proxy={settings.PROXY_HOST} " if settings.PROXY_HOST else ""
|
||||
|
||||
# Todo:目前proxychains4的临时调用命令不支持socks5h和socks4a,需要生成临时配置文件才能解决,后面考虑支持一下
|
||||
elif protocol in {"socks4", "socks4a", "socks5", "socks5h"}:
|
||||
# 没有主机名,端口号
|
||||
if not host or not port:
|
||||
PIP_PROXY = f" -i {settings.PIP_PROXY} " if settings.PIP_PROXY else ""
|
||||
# 将拓展的socks协议转换为proxychains4支持的socks4和socks5
|
||||
else:
|
||||
if protocol in {"socks5", "socks5h"}:
|
||||
protocol = "socks5"
|
||||
elif protocol in {"socks4", "socks4a"}:
|
||||
protocol = "socks4"
|
||||
# 生成配置
|
||||
PROXY_CHAINS = f"proxychains4 -f <( echo -e '[ProxyList]\n{protocol} {host} {port} {username} {password}')"
|
||||
|
||||
# 不支持的协议类型
|
||||
else:
|
||||
PIP_PROXY = f" -i {settings.PIP_PROXY} " if settings.PIP_PROXY else ""
|
||||
|
||||
# 本地优先,镜像站不存在时,不使用全局代理
|
||||
else:
|
||||
PIP_PROXY = f" -i {settings.PIP_PROXY} " if settings.PIP_PROXY else ""
|
||||
|
||||
SystemUtils.execute(f"{PROXY_CHAINS} pip install -r {requirements_file} {PIP_PROXY} > /dev/null 2>&1")
|
||||
SystemUtils.execute(f"pip install -r {requirements_file} {settings.PIP_OPTIONS} > /dev/null 2>&1")
|
||||
# 安装成功后统计
|
||||
self.install_reg(pid)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user