qingxu99 commited on
Commit
869de46
1 Parent(s): 6ce9b72

自动更新程序+自动pip包安装

Browse files
Files changed (1) hide show
  1. check_proxy.py +8 -4
check_proxy.py CHANGED
@@ -67,12 +67,15 @@ def patch_and_restart(path):
67
  '另外您可以随时在history子文件夹下找回旧版的程序。')
68
  shutil.copyfile('config.py', 'config_private.py')
69
  distutils.dir_util.copy_tree(path+'/chatgpt_academic-master', './')
70
- print('更新完成,您可以随时在history子文件夹下找回旧版的程序,5s之后重启')
 
 
 
71
  for i in reversed(range(5)):
72
  time.sleep(1)
73
  print(i)
74
  print(' ------------------------------ -----------------------------------')
75
- os.execl(sys.executable, *sys.argv)
76
 
77
 
78
  def get_current_version():
@@ -107,10 +110,11 @@ def auto_update():
107
  current_version = f.read()
108
  current_version = json.loads(current_version)['version']
109
  if (remote_version - current_version) >= 0.05:
110
- print(
 
111
  f'\n新版本可用。新版本:{remote_version},当前版本:{current_version}。{new_feature}')
112
  print('(1)Github更新地址:\nhttps://github.com/binary-husky/chatgpt_academic\n')
113
- user_instruction = input('(2)是否一键更新代码(Y/y+回车=确认,输入其他/无输入+回车=不更新)?')
114
  if user_instruction in ['Y', 'y']:
115
  path = backup_and_download(current_version, remote_version)
116
  try:
 
67
  '另外您可以随时在history子文件夹下找回旧版的程序。')
68
  shutil.copyfile('config.py', 'config_private.py')
69
  distutils.dir_util.copy_tree(path+'/chatgpt_academic-master', './')
70
+ import subprocess
71
+ print('更新包依赖中……')
72
+ subprocess.check_call([sys.executable, '-m', 'pip', 'install', '-r', 'requirements.txt'])
73
+ print('更新完成,您可以随时在history子文件夹下找回旧版的程序,5s之后重启,如果没能重启成功,您需要手动安装新增的依赖库 `python -m pip install -r requirements.txt` ')
74
  for i in reversed(range(5)):
75
  time.sleep(1)
76
  print(i)
77
  print(' ------------------------------ -----------------------------------')
78
+ os.execl(sys.executable, sys.executable, *sys.argv)
79
 
80
 
81
  def get_current_version():
 
110
  current_version = f.read()
111
  current_version = json.loads(current_version)['version']
112
  if (remote_version - current_version) >= 0.05:
113
+ from colorful import print亮黄
114
+ print亮黄(
115
  f'\n新版本可用。新版本:{remote_version},当前版本:{current_version}。{new_feature}')
116
  print('(1)Github更新地址:\nhttps://github.com/binary-husky/chatgpt_academic\n')
117
+ user_instruction = input('(2)是否一键更新代码(Y+回车=确认,输入其他/无输入+回车=不更新)?')
118
  if user_instruction in ['Y', 'y']:
119
  path = backup_and_download(current_version, remote_version)
120
  try: