mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-15 15:00:58 +00:00
feat: 插件更新异常处理
This commit is contained in:
@@ -98,28 +98,33 @@ class PluginUpdateCommand(AbstractCommandNode):
|
|||||||
|
|
||||||
reply = []
|
reply = []
|
||||||
def closure():
|
def closure():
|
||||||
import pkg.utils.context
|
try:
|
||||||
updated = []
|
import pkg.utils.context
|
||||||
for key in plugin_list:
|
updated = []
|
||||||
plugin = plugin_list[key]
|
for key in plugin_list:
|
||||||
if updater.is_repo("/".join(plugin['path'].split('/')[:-1])):
|
plugin = plugin_list[key]
|
||||||
success = updater.pull_latest("/".join(plugin['path'].split('/')[:-1]))
|
if updater.is_repo("/".join(plugin['path'].split('/')[:-1])):
|
||||||
if success:
|
success = updater.pull_latest("/".join(plugin['path'].split('/')[:-1]))
|
||||||
updated.append(plugin['name'])
|
if success:
|
||||||
|
updated.append(plugin['name'])
|
||||||
|
|
||||||
# 检查是否有requirements.txt
|
# 检查是否有requirements.txt
|
||||||
pkg.utils.context.get_qqbot_manager().notify_admin("正在安装依赖...")
|
pkg.utils.context.get_qqbot_manager().notify_admin("正在安装依赖...")
|
||||||
for key in plugin_list:
|
for key in plugin_list:
|
||||||
plugin = plugin_list[key]
|
plugin = plugin_list[key]
|
||||||
if os.path.exists("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt"):
|
if os.path.exists("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt"):
|
||||||
logging.info("{}检测到requirements.txt,安装依赖".format(plugin['name']))
|
logging.info("{}检测到requirements.txt,安装依赖".format(plugin['name']))
|
||||||
import pkg.utils.pkgmgr
|
import pkg.utils.pkgmgr
|
||||||
pkg.utils.pkgmgr.install_requirements("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt")
|
pkg.utils.pkgmgr.install_requirements("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt")
|
||||||
|
|
||||||
import main
|
import main
|
||||||
main.reset_logging()
|
main.reset_logging()
|
||||||
|
|
||||||
|
pkg.utils.context.get_qqbot_manager().notify_admin("已更新插件: {}".format(", ".join(updated)))
|
||||||
|
except Exception as e:
|
||||||
|
logging.error("插件更新失败:{}".format(e))
|
||||||
|
pkg.utils.context.get_qqbot_manager().notify_admin("插件更新失败:{} 请尝试手动更新插件".format(e))
|
||||||
|
|
||||||
pkg.utils.context.get_qqbot_manager().notify_admin("已更新插件: {}".format(", ".join(updated)))
|
|
||||||
|
|
||||||
threading.Thread(target=closure).start()
|
threading.Thread(target=closure).start()
|
||||||
reply = ["[bot]正在更新所有插件,请勿重复发起..."]
|
reply = ["[bot]正在更新所有插件,请勿重复发起..."]
|
||||||
|
|||||||
Reference in New Issue
Block a user