mirror of
https://github.com/RockChinQ/QChatGPT.git
synced 2024-11-16 19:57:04 +08:00
perf: 完善未启动情况下的自动更新
This commit is contained in:
parent
7a04ef0985
commit
9e28298250
3
main.py
3
main.py
|
@ -343,8 +343,9 @@ if __name__ == '__main__':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif len(sys.argv) > 1 and sys.argv[1] == 'update':
|
elif len(sys.argv) > 1 and sys.argv[1] == 'update':
|
||||||
|
print("正在进行程序更新...")
|
||||||
import pkg.utils.updater as updater
|
import pkg.utils.updater as updater
|
||||||
updater.update_all()
|
updater.update_all(cli=True)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
# import pkg.utils.configmgr
|
# import pkg.utils.configmgr
|
||||||
|
|
|
@ -54,7 +54,7 @@ def get_current_tag() -> str:
|
||||||
return current_tag
|
return current_tag
|
||||||
|
|
||||||
|
|
||||||
def update_all(cli: bool=False) -> bool:
|
def update_all(cli: bool = False) -> bool:
|
||||||
"""检查更新并下载源码"""
|
"""检查更新并下载源码"""
|
||||||
current_tag = get_current_tag()
|
current_tag = get_current_tag()
|
||||||
|
|
||||||
|
@ -69,12 +69,19 @@ def update_all(cli: bool=False) -> bool:
|
||||||
|
|
||||||
if latest_rls == {}:
|
if latest_rls == {}:
|
||||||
latest_rls = rls
|
latest_rls = rls
|
||||||
logging.info("更新日志: {}".format(rls_notes))
|
if not cli:
|
||||||
|
logging.info("更新日志: {}".format(rls_notes))
|
||||||
|
else:
|
||||||
|
print("更新日志: {}".format(rls_notes))
|
||||||
|
|
||||||
if latest_rls == {}: # 没有新版本
|
if latest_rls == {}: # 没有新版本
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# 下载最新版本的zip到temp目录
|
# 下载最新版本的zip到temp目录
|
||||||
logging.info("开始下载最新版本: {}".format(latest_rls['zipball_url']))
|
if not cli:
|
||||||
|
logging.info("开始下载最新版本: {}".format(latest_rls['zipball_url']))
|
||||||
|
else:
|
||||||
|
print("开始下载最新版本: {}".format(latest_rls['zipball_url']))
|
||||||
zip_url = latest_rls['zipball_url']
|
zip_url = latest_rls['zipball_url']
|
||||||
zip_resp = requests.get(url=zip_url)
|
zip_resp = requests.get(url=zip_url)
|
||||||
zip_data = zip_resp.content
|
zip_data = zip_resp.content
|
||||||
|
@ -87,7 +94,10 @@ def update_all(cli: bool=False) -> bool:
|
||||||
with open("temp/updater/{}.zip".format(latest_rls['tag_name']), "wb") as f:
|
with open("temp/updater/{}.zip".format(latest_rls['tag_name']), "wb") as f:
|
||||||
f.write(zip_data)
|
f.write(zip_data)
|
||||||
|
|
||||||
logging.info("下载最新版本完成: {}".format("temp/updater/{}.zip".format(latest_rls['tag_name'])))
|
if not cli:
|
||||||
|
logging.info("下载最新版本完成: {}".format("temp/updater/{}.zip".format(latest_rls['tag_name'])))
|
||||||
|
else:
|
||||||
|
print("下载最新版本完成: {}".format("temp/updater/{}.zip".format(latest_rls['tag_name'])))
|
||||||
|
|
||||||
# 解压zip到temp/updater/<tag_name>/
|
# 解压zip到temp/updater/<tag_name>/
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
Loading…
Reference in New Issue
Block a user