e6875f0b4b
- 13-service async plugin framework - Textual TUI with CLI fallback - Plugin hot-reload + permission system - Web management panel (aiohttp) - Bridge-based inter-module communication - 10 regression tests Fixes applied: - PBKDF2-SHA256 auth (was plain SHA256) - Auth bypass removed (was allow-all on fail) - Bare excepts replaced with logged errors - CatFramework/DreamSu -> SenSu naming unified - ServiceManager: health checks + startup_order - Env var credentials (SENSU_ADMIN_PASSWORD etc)
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import logging
|
|
import asyncio
|
|
from typing import Dict, Any
|
|
from aiohttp import web
|
|
|
|
try:
|
|
from fmfuncs.plugin_command_decorator import plugin_command, command
|
|
except ImportError:
|
|
def plugin_command(name=None, description=None, permissions=None):
|
|
def decorator(func): return func
|
|
return decorator
|
|
command = plugin_command
|
|
|
|
try:
|
|
from bridges.plugin_network_bridge import PluginNetworkBridge
|
|
except ImportError:
|
|
class PluginNetworkBridge:
|
|
def __init__(self, *args): pass
|
|
async def register_http_route(self, *a, **k): pass
|
|
async def register_websocket(self, *a, **k): pass
|
|
async def broadcast_websocket(self, *a, **k): pass
|
|
def get_network_info(self): return {'plugin_name': '', 'registered_routes': [], 'websocket_handlers': [], 'base_url': '不可用'}
|
|
async def setup_data_transfer(self, *a, **k): pass
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
class Plugin:
|
|
"""${plugin_name} 插件"""
|
|
|
|
def __init__(self, plugin_name: str, config: Dict, bridge):
|
|
self.plugin_name = plugin_name
|
|
self.config = config
|
|
self.bridge = bridge
|
|
self.network_bridge = None
|
|
self.is_running = False
|
|
logger.debug(f"插件初始化: {plugin_name}")
|
|
|
|
async def initialize(self):
|
|
logger.info(f"初始化插件: {self.plugin_name}")
|
|
self.is_running = True
|
|
logger.debug(f"插件初始化完成: {self.plugin_name}")
|
|
|
|
async def shutdown(self):
|
|
logger.info(f"关闭插件: {self.plugin_name}")
|
|
self.is_running = False
|
|
self.bridge.cleanup_plugin_subscriptions(self.plugin_name)
|
|
logger.debug(f"插件关闭完成: {self.plugin_name}")
|