From fb7669ddadb6b8c6dc2d4c226d72a55733dbbe68 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Sun, 1 Oct 2023 16:20:51 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BE=9D=E8=B5=96=E5=BA=93=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/main.py b/main.py index 8252213a8..8d474a21a 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,7 @@ def privider_chooser(cfg): l.append('openai_official') return l -def check_env(): +def check_env(ch_mirror=False): if not (sys.version_info.major == 3 and sys.version_info.minor >= 8): print("请使用Python3.8运行本项目") input("按任意键退出...") @@ -60,7 +60,11 @@ def check_env(): pth = 'QQChannelChatGPT'+ os.sep +'requirements.txt' print("正在检查更新第三方库...") try: - pipmain(['install', '-r', pth, '--quiet']) + if ch_mirror: + print("使用阿里云镜像") + pipmain(['install', '-r', pth, '-i', 'https://mirrors.aliyun.com/pypi/simple/', '--quiet']) + else: + pipmain(['install', '-r', pth, '--quiet']) except BaseException as e: print(e) while True: @@ -96,17 +100,20 @@ def get_platform(): print("other") if __name__ == "__main__": - check_env() - # 获取参数 args = sys.argv - if len(args) > 1: - if args[1] == '-replit': - print("[System] 启动Replit Web保活服务...") - try: - from webapp_replit import keep_alive - keep_alive() - except BaseException as e: - print(e) - print(f"[System-err] Replit Web保活服务启动失败:{str(e)}") + + if '-cn' in args: + check_env(True) + else: + check_env() + + if '-replit' in args: + print("[System] 启动Replit Web保活服务...") + try: + from webapp_replit import keep_alive + keep_alive() + except BaseException as e: + print(e) + print(f"[System-err] Replit Web保活服务启动失败:{str(e)}") main()