Debug: fix headless mode, plugin compat, psutil optional, module imports
- headless: TUI skip now works correctly - example_plugin: keyword args compat (plugin_name=, config=, bridge=) - sysmon: psutil made optional (graceful degrade) - tui_service: SysMonWidget optional - All 22 modules import clean, 23 tests pass, integration verified
This commit is contained in:
@@ -9,7 +9,6 @@ from textual.app import App
|
||||
from textual.containers import Container, ScrollableContainer
|
||||
from textual.widgets import Static, Input, Header, Footer
|
||||
from textual.reactive import reactive
|
||||
from services.sysmon_widget import SysMonWidget
|
||||
from typing import List, Dict
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
@@ -659,42 +658,6 @@ class TUIFramework(App):
|
||||
except Exception as e:
|
||||
print(f"❌ 关闭TUI时出错: {str(e)}")
|
||||
|
||||
|
||||
def _start_plugin_status_refresh(self):
|
||||
async def refresh():
|
||||
while True:
|
||||
try:
|
||||
ps = self.service_manager.get_service("plugin")
|
||||
if ps and hasattr(ps, "plugin_status"):
|
||||
lines = []
|
||||
for name, status in ps.plugin_status.items():
|
||||
icon = {"running":"🟢","error":"🔴","loading":"🟡","unloaded":"⚫"}.get(str(status),"⚪")
|
||||
lines.append(f"{icon} {name}: {status}")
|
||||
widget = self.tui_app.query_one(SysMonWidget)
|
||||
widget.update_plugins("\n".join(lines) if lines else "无已加载插件")
|
||||
except: pass
|
||||
await asyncio.sleep(3)
|
||||
import asyncio
|
||||
asyncio.create_task(refresh())
|
||||
|
||||
|
||||
def _get_suggester(self):
|
||||
from textual.suggester import Suggester
|
||||
class CmdSuggester(Suggester):
|
||||
async def get_suggestion(self, value):
|
||||
try:
|
||||
cs = self.app.query_one("#input-area").app
|
||||
names = ["help","status","history","testlog","netdiag",
|
||||
"permissions","pmpending","pmhelp","echo","plugin_status",
|
||||
"scroll","autoscroll","create-plugin","exit","quit"]
|
||||
if not value: return None
|
||||
for n in names:
|
||||
if n.startswith(value) and n != value:
|
||||
return n
|
||||
except: pass
|
||||
return None
|
||||
return CmdSuggester()
|
||||
|
||||
class TuiService:
|
||||
"""TUI服务"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user