diff --git a/pgpl/managers.py b/pgpl/managers.py index 63c6039..7e7f0a0 100644 --- a/pgpl/managers.py +++ b/pgpl/managers.py @@ -140,7 +140,7 @@ def __init__(self, installer_config, progress_tracker=None): self.InstallDependencies = installer_config["InstallDependencies"] self.PypiMirror = installer_config["PypiMirror"] if self.PypiMirror == "AUTO" or self.PypiMirror == "": - self.PypiMirror = select_fastest_url(["http://pypi.org/simple", "http://pypi.tuna.tsinghua.edu.cn/simple", "http://mirrors.aliyun.com/pypi/simple"]) + self.PypiMirror = select_fastest_url(["https://pypi.org/simple", "http://pypi.tuna.tsinghua.edu.cn/simple", "http://mirrors.aliyun.com/pypi/simple", "https://mirrors.bfsu.edu.cn/pypi/web"]) self.pip_arg = [] if self.PypiMirror: @@ -213,7 +213,7 @@ def __init__(self, installer_config, progress_tracker:ProgressTracker=None): }[PROXY_LANG] self.PypiMirror = installer_config["PypiMirror"] if self.PypiMirror == "AUTO" or self.PypiMirror == "": - self.PypiMirror = select_fastest_url(["http://pypi.org/simple", "http://pypi.tuna.tsinghua.edu.cn/simple", "http://mirrors.aliyun.com/pypi/simple"]) + self.PypiMirror = select_fastest_url(["https://pypi.org/simple", "http://pypi.tuna.tsinghua.edu.cn/simple", "http://mirrors.aliyun.com/pypi/simple", "https://mirrors.bfsu.edu.cn/pypi/web"]) # https://registry.npmmirror.com/-/binary/python/3.10.1/python-3.10.1-amd64.exe # paths = '' # for i in os.environ['PATH'].split(';'): @@ -295,4 +295,4 @@ def run(self): # self.execute(f'{self.python_path} -m pip') # if __name__ == '__main__': - #MiniCondaManager(CONFIG_TEMPLATE).create_python() \ No newline at end of file + #MiniCondaManager(CONFIG_TEMPLATE).create_python() diff --git a/pgpl/utils.py b/pgpl/utils.py index 12a8d64..715fa25 100644 --- a/pgpl/utils.py +++ b/pgpl/utils.py @@ -370,13 +370,24 @@ def select_fastest_url(urls:typing.List[str]): requests.packages.urllib3.disable_warnings() for url in urls: total_time = 0 - domain = url[:url.replace("http://", '').replace("https://", "").find('/') + url.find('://') + 3] + domain = url[:url.replace("http://", '').replace("https://", "").rfind('/') + url.find('://') + 3] for i in range(4): pt = time.time() try: r = requests.get(domain, verify=False, proxies=None, timeout=3) - use_time = time.time()-pt - logger.info(f'get {domain} code: {r.status_code} time: {use_time}') + if r.status_code == 200: + try_download_url = f"{domain}/packages/00/00/0188b746eefaea75d665b450c9165451a66aae541e5f73db4456eebc0289/loginhelper-0.0.5-py3-none-any.whl" + r2 = requests.get(try_download_url, verify=False, proxies=None, timeout=300) + if r2.status_code == 200: + use_time = time.time()-pt + logger.info(f'get {domain} code: {r.status_code} time: {use_time}') + else: + total_time = 9999999999999.999999999 + logger.info(f'get {domain} error: 被风控/无法下载 code_1:{r.status_code} code_1:{r2.status_code} time: {total_time}') + break + else: + use_time = time.time() - pt + logger.info(f'get {domain} code: {r.status_code} time: {use_time}') if r.status_code > 210: total_time += 4 else: @@ -429,4 +440,4 @@ def proxy_info(): ":gotAdmin\n"+\ " pushd \"%CD%\"\n"+\ " CD /D \"%~dp0\"\n"+\ -":-------------------------------------- \n" \ No newline at end of file +":-------------------------------------- \n"