Initial commit - Phase 3/4

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
michael
2026-01-06 13:45:29 -08:00
parent 1da6730735
commit 4f35df1781
323 changed files with 98287 additions and 1195 deletions

View File

@@ -1,13 +1,30 @@
"""Hello World example plugin for Dangerous Pi."""
"""Hello World example plugin for Dangerous Pi.
This plugin demonstrates the plugin framework capabilities including:
- Lifecycle methods (on_load, on_enable, on_disable, on_unload)
- Hook registration
- Header widget display
"""
import sys
from pathlib import Path
# Add app directory to path for imports
app_path = Path(__file__).parent.parent.parent
if str(app_path) not in sys.path:
sys.path.insert(0, str(app_path))
from backend.managers.plugin_manager import PluginBase, PluginMetadata
# Import PluginBase from the already-loaded module to ensure class identity matches
# This is necessary because the plugin manager uses issubclass() check
# Try both module name variants (depends on how the app is started)
_plugin_manager_module = (
sys.modules.get('app.backend.managers.plugin_manager') or
sys.modules.get('backend.managers.plugin_manager')
)
if _plugin_manager_module:
PluginBase = _plugin_manager_module.PluginBase
PluginMetadata = _plugin_manager_module.PluginMetadata
WidgetSeverity = _plugin_manager_module.WidgetSeverity
else:
# Fallback for standalone testing
from pathlib import Path
app_path = Path(__file__).parent.parent.parent
if str(app_path) not in sys.path:
sys.path.insert(0, str(app_path))
from backend.managers.plugin_manager import PluginBase, PluginMetadata, WidgetSeverity
class HelloWorldPlugin(PluginBase):
@@ -26,6 +43,17 @@ class HelloWorldPlugin(PluginBase):
"""Called when the plugin is enabled."""
print("Hello World Plugin: Enabled!")
# Register a header widget to show plugin is active
self.register_widget(
widget_id="status",
severity=WidgetSeverity.SUCCESS,
message="Hello World plugin active",
icon="👋",
dismissible=True,
action_label="Settings",
action_url="/settings"
)
# Register a hook for PM3 commands
async def pm3_command_hook(command: str):
"""Hook that logs PM3 commands."""
@@ -47,6 +75,9 @@ class HelloWorldPlugin(PluginBase):
"""Called when the plugin is disabled."""
print(f"Hello World Plugin: Disabled! (processed {self.counter} commands)")
# Remove the header widget
self.unregister_widget("status")
async def on_unload(self):
"""Called when the plugin is unloaded."""
print("Hello World Plugin: Unloaded! Goodbye!")