去除Windows的重启策略
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
from typing import Dict, Any, List, Optional, Tuple
|
||||
|
||||
from plugin_common.message_plugin_interface import MessagePluginInterface
|
||||
@@ -9,36 +7,6 @@ from plugin_common.plugin_interface import PluginStatus
|
||||
from utils.robot_cmd.robot_command import Feature, PermissionStatus
|
||||
|
||||
|
||||
# 动态导入win_click.py
|
||||
def import_win_click():
|
||||
"""动态导入win_click模块"""
|
||||
try:
|
||||
# 首先尝试从项目根目录导入
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))
|
||||
win_click_path = os.path.join(project_root, "win_click.py")
|
||||
|
||||
if not os.path.exists(win_click_path):
|
||||
# 尝试在utils目录下查找
|
||||
win_click_path = os.path.join(project_root, "utils", "win_click.py")
|
||||
|
||||
if os.path.exists(win_click_path):
|
||||
import importlib.util
|
||||
import sys
|
||||
|
||||
spec = importlib.util.spec_from_file_location("win_click", win_click_path)
|
||||
win_click = importlib.util.module_from_spec(spec)
|
||||
sys.modules["win_click"] = win_click
|
||||
spec.loader.exec_module(win_click)
|
||||
return win_click
|
||||
else:
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"导入win_click模块失败: {e}")
|
||||
return None
|
||||
|
||||
|
||||
win_click = import_win_click()
|
||||
|
||||
|
||||
class SystemUpdaterPlugin(MessagePluginInterface):
|
||||
"""系统更新插件"""
|
||||
@@ -88,9 +56,6 @@ class SystemUpdaterPlugin(MessagePluginInterface):
|
||||
self.admin_wxids = plugin_config.get("admin_wxids", [])
|
||||
self.enable = plugin_config.get("enable", True)
|
||||
|
||||
# 检查win_click模块是否可用
|
||||
if win_click is None:
|
||||
self.LOG.error("无法导入win_click模块,插件功能将受限")
|
||||
|
||||
self.LOG.info(f"[{self.name}] 插件初始化完成,指令:{self._commands}")
|
||||
return True
|
||||
@@ -152,26 +117,10 @@ class SystemUpdaterPlugin(MessagePluginInterface):
|
||||
except:
|
||||
pass
|
||||
|
||||
# 检查win_click模块是否可用
|
||||
if win_click is None:
|
||||
self.message_util.send_text("⚠️ 无法执行更新操作,系统缺少必要的组件",
|
||||
(roomid if roomid else sender), sender)
|
||||
return True, "缺少win_click模块"
|
||||
|
||||
# 发送更新通知
|
||||
self.message_util.send_text(f"🔄 系统即将更新并重启,等待时间设置为{wait_time}秒...",
|
||||
(roomid if roomid else sender), sender)
|
||||
|
||||
# 启动更新流程
|
||||
def update_thread():
|
||||
try:
|
||||
self.LOG.info(f"开始系统更新流程,等待时间: {wait_time}秒")
|
||||
win_click.update_system(wait_time)
|
||||
except Exception as e:
|
||||
self.LOG.error(f"系统更新失败: {e}")
|
||||
|
||||
# 在新线程中启动更新,避免阻塞消息处理
|
||||
threading.Thread(target=update_thread, daemon=True).start()
|
||||
|
||||
return True, "系统更新中"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user