mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 20:14:36 +00:00
perf: 自动更新时的异常处理
This commit is contained in:
1
main.py
1
main.py
@@ -115,7 +115,6 @@ def stop():
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('程序启动')
|
||||
# 检查是否有config.py,如果没有就把config-template.py复制一份,并退出程序
|
||||
if not os.path.exists('config.py'):
|
||||
shutil.copy('config-template.py', 'config.py')
|
||||
|
||||
@@ -167,7 +167,11 @@ def process_message(launcher_type: str, launcher_id: int, text_message: str, mes
|
||||
threading.Thread(target=reload_task, daemon=True).start()
|
||||
elif cmd == 'update' and launcher_type == 'person' and launcher_id == config.admin_qq:
|
||||
def update_task():
|
||||
pkg.utils.updater.update_all()
|
||||
try:
|
||||
pkg.utils.updater.update_all()
|
||||
except Exception as e0:
|
||||
pkg.utils.context.get_qqbot_manager().notify_admin("更新失败:{}".format(e0))
|
||||
return
|
||||
pkg.utils.reloader.reload_all()
|
||||
|
||||
threading.Thread(target=update_task, daemon=True).start()
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import dulwich.porcelain
|
||||
|
||||
|
||||
def update_all():
|
||||
try:
|
||||
from dulwich import porcelain
|
||||
repo = porcelain.open_repo('.')
|
||||
porcelain.pull(repo)
|
||||
except ModuleNotFoundError:
|
||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
||||
except dulwich.porcelain.DivergedBranches:
|
||||
raise Exception("分支不一致,自动更新仅支持master分支,请手动更新")
|
||||
|
||||
Reference in New Issue
Block a user