mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-12 00:36:03 +00:00
chore: stash
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import threading
|
||||
import asyncio
|
||||
import traceback
|
||||
|
||||
from .. import aamgr
|
||||
@@ -20,9 +21,9 @@ class UpdateCommand(aamgr.AbstractCommandNode):
|
||||
import pkg.utils.reloader
|
||||
import pkg.utils.context
|
||||
|
||||
def update_task():
|
||||
async def update_task():
|
||||
try:
|
||||
if pkg.utils.updater.update_all():
|
||||
if await pkg.utils.updater.update_all():
|
||||
pkg.utils.context.get_qqbot_manager().notify_admin("更新完成, 请手动重启程序。")
|
||||
else:
|
||||
pkg.utils.context.get_qqbot_manager().notify_admin("无新版本")
|
||||
@@ -31,7 +32,10 @@ class UpdateCommand(aamgr.AbstractCommandNode):
|
||||
pkg.utils.context.get_qqbot_manager().notify_admin("更新失败:{}".format(e0))
|
||||
return
|
||||
|
||||
threading.Thread(target=update_task, daemon=True).start()
|
||||
def wrapper():
|
||||
asyncio.run(update_task())
|
||||
|
||||
threading.Thread(target=wrapper).start()
|
||||
|
||||
reply = ["[bot]正在更新,请耐心等待,请勿重复发起更新..."]
|
||||
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import logging
|
||||
import os.path
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
from . import constants
|
||||
from . import network
|
||||
from . import context
|
||||
|
||||
|
||||
def check_dulwich_closure():
|
||||
@@ -105,9 +109,12 @@ def compare_version_str(v0: str, v1: str) -> int:
|
||||
return 0
|
||||
|
||||
|
||||
def update_all(cli: bool = False) -> bool:
|
||||
async def update_all(cli: bool = False) -> bool:
|
||||
"""检查更新并下载源码"""
|
||||
start_time = time.time()
|
||||
|
||||
current_tag = get_current_tag()
|
||||
old_tag = current_tag
|
||||
|
||||
rls_list = get_release_list()
|
||||
|
||||
@@ -200,6 +207,13 @@ def update_all(cli: bool = False) -> bool:
|
||||
with open("current_tag", "w") as f:
|
||||
f.write(current_tag)
|
||||
|
||||
await context.get_center_v2_api().main.post_update_record(
|
||||
spent_seconds=int(time.time()-start_time),
|
||||
infer_reason="update",
|
||||
old_version=old_tag,
|
||||
new_version=current_tag,
|
||||
)
|
||||
|
||||
# 通知管理员
|
||||
if not cli:
|
||||
import pkg.utils.context
|
||||
|
||||
Reference in New Issue
Block a user