mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-10-13 10:36:35 +00:00
#556 made a missing web_display_autostart mean "start" (only an explicit false/off keeps the web interface down), but the diagnostics still said otherwise: diagnose_web_ui.sh reported a missing key as "defaults to false", diagnose_web_interface.sh said the web interface "will not start unless this is set to true" and recommended enabling it, and debug_web_manual.py printed False. Troubleshooting a down web UI pointed users at a non-cause. Both shell scripts now evaluate the setting with the launcher's own autostart_enabled() (inline fallback if it cannot be imported) and report on / off / not set (on) / unparseable config; debug_web_manual.py uses the same function. They also check web_interface/blueprints/api_v3/ __init__.py: api_v3.py became a package in #553, so every healthy checkout was reported as missing a file. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
97 lines
3.1 KiB
Python
97 lines
3.1 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Web Interface Manual Debug Script
|
|
Run this to diagnose why web_interface/start.py isn't working
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import traceback
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
print("🔍 LED Matrix Web Interface Debug Tool")
|
|
print("=" * 50)
|
|
|
|
# Change to project root (two levels up from scripts/debug/)
|
|
project_root = Path(__file__).parent.parent.parent.resolve()
|
|
os.chdir(project_root)
|
|
print(f"📁 Working directory: {os.getcwd()}")
|
|
|
|
# Add to Python path
|
|
sys.path.insert(0, str(project_root))
|
|
print(f"🔗 Python path includes: {project_root}")
|
|
|
|
print("\n1. Testing basic imports...")
|
|
try:
|
|
import flask
|
|
print(f" ✅ Flask: {flask.__version__}")
|
|
except ImportError as e:
|
|
print(f" ❌ Flask missing: {e}")
|
|
return False
|
|
|
|
try:
|
|
from src.config_manager import ConfigManager
|
|
print(" ✅ ConfigManager imported")
|
|
except Exception as e:
|
|
print(f" ❌ ConfigManager failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n2. Testing web interface imports...")
|
|
try:
|
|
from web_interface.app import app
|
|
print(" ✅ web_interface.app imported")
|
|
print(f" 📋 App object: {app}")
|
|
except Exception as e:
|
|
print(f" ❌ web_interface.app failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n3. Checking config...")
|
|
try:
|
|
config_manager = ConfigManager()
|
|
config = config_manager.load_config()
|
|
print(" ✅ Config loaded")
|
|
|
|
# Same rule ledmatrix-web.service applies: only an explicit false/off
|
|
# keeps the web interface down; a missing key means on.
|
|
sys.path.insert(0, str(project_root / 'scripts' / 'utils'))
|
|
from start_web_conditionally import autostart_enabled
|
|
raw = config.get('web_display_autostart', '(not set, defaults to on)')
|
|
state = 'starts' if autostart_enabled(config) else 'will NOT start'
|
|
print(f" 🔧 web_display_autostart: {raw} (web interface {state})")
|
|
except Exception as e:
|
|
print(f" ❌ Config check failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n4. Testing Flask startup...")
|
|
try:
|
|
print(" 🚀 Starting Flask app...")
|
|
print(" 📍 Will run on: http://0.0.0.0:5000")
|
|
print(" ⏹️ Press Ctrl+C to stop")
|
|
|
|
# Run the app (debug mode controlled by env var to satisfy security scanners)
|
|
_debug = os.environ.get('LEDMATRIX_FLASK_DEBUG', '0') == '1'
|
|
app.run(host='0.0.0.0', port=5000, debug=_debug)
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n ⏹️ Server stopped by user")
|
|
return True
|
|
except Exception as e:
|
|
print(f" ❌ Flask startup failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
success = main()
|
|
if success:
|
|
print("\n✅ Debug completed successfully")
|
|
else:
|
|
print("\n❌ Debug found issues - check output above")
|
|
except Exception as e:
|
|
print(f"\n💥 Debug script crashed: {e}")
|
|
traceback.print_exc()
|