🗑️ Refactor: Remove obsolete printer check scripts and update app logic
**Änderungen:** - ✅ check_printer_ips.py und check_printers.py: Entfernt nicht mehr benötigte Skripte zur Überprüfung von Drucker-IP-Adressen. - ✅ DRUCKER_STATUS_REQUIREMENTS.md: Veraltete Anforderungen entfernt. - ✅ setup_standard_printers.py: Anpassungen zur Vereinheitlichung der Drucker-IP. - ✅ app.py: Logik zur Filterung offline/unreachable Drucker aktualisiert. **Ergebnis:** - Bereinigung des Codes durch Entfernen nicht mehr benötigter Dateien. - Optimierte Logik zur Handhabung von Druckerstatus in der Anwendung. 🤖 Generated with [Claude Code](https://claude.ai/code)
This commit is contained in:
@ -1 +1,251 @@
|
||||
|
||||
#!/usr/bin/env python3.11
|
||||
"""
|
||||
Development-Startskript für MYP System
|
||||
Lokale Entwicklung mit Debug-Features und flexibler Konfiguration
|
||||
|
||||
Dieses Skript startet das System im Development-Modus mit allen
|
||||
erforderlichen Debug-Features und Entwicklerfreundlichkeit.
|
||||
|
||||
Verfügbare Modi:
|
||||
- development: Lokale Entwicklung (debug + flexibel)
|
||||
- production: Mercedes-Benz TBA Air-Gapped (optimiert + sicher)
|
||||
|
||||
Verwendung:
|
||||
python start_development.py
|
||||
|
||||
Umgebungsvariablen:
|
||||
FLASK_ENV=development
|
||||
USE_PRODUCTION_CONFIG=false
|
||||
MERCEDES_ENVIRONMENT=development
|
||||
DEBUG_MODE=true
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
# Development-Environment setzen
|
||||
os.environ['FLASK_ENV'] = 'development'
|
||||
os.environ['USE_PRODUCTION_CONFIG'] = 'false'
|
||||
os.environ['MERCEDES_ENVIRONMENT'] = 'development'
|
||||
os.environ['DEBUG_MODE'] = 'true'
|
||||
|
||||
# SSL für Development optional
|
||||
os.environ['FLASK_SSL_REQUIRED'] = 'false'
|
||||
|
||||
# Logging-Level
|
||||
os.environ['LOG_LEVEL'] = 'DEBUG'
|
||||
|
||||
# Development-Optimierungen
|
||||
os.environ['PYTHONDONTWRITEBYTECODE'] = '0' # Bytecode für Debugging
|
||||
os.environ['FLASK_DEBUG'] = '1'
|
||||
|
||||
def print_development_banner():
|
||||
"""Zeigt den Development-Start-Banner"""
|
||||
banner = f"""
|
||||
{'='*80}
|
||||
🛠️ MYP DEVELOPMENT SYSTEM - LOKALE ENTWICKLUNG
|
||||
{'='*80}
|
||||
|
||||
🚀 Environment: Development/Testing
|
||||
🔓 Security: Relaxed (HTTP + Debug + CSRF)
|
||||
🌐 Network: Online-Mode (External APIs verfügbar)
|
||||
⚡ Performance: Debug-optimiert (Live-Reload + Pretty JSON)
|
||||
📊 Monitoring: Development-Grade (Minimal)
|
||||
🔍 Logging: Verbose Debug-Logging
|
||||
🎯 Modi: Development + Production (konsolidiert)
|
||||
📅 Start-Zeit: {datetime.now().strftime('%d.%m.%Y %H:%M:%S')}
|
||||
|
||||
{'='*80}
|
||||
"""
|
||||
print(banner)
|
||||
|
||||
def check_development_requirements():
|
||||
"""Prüft Development-Voraussetzungen"""
|
||||
print("🔍 Prüfe Development-Voraussetzungen...")
|
||||
|
||||
requirements = []
|
||||
|
||||
# Python-Version prüfen
|
||||
if sys.version_info < (3, 8):
|
||||
requirements.append("❌ Python 3.8+ erforderlich")
|
||||
else:
|
||||
requirements.append("✅ Python-Version OK")
|
||||
|
||||
# Erforderliche Dateien prüfen
|
||||
required_files = [
|
||||
'app.py',
|
||||
'models.py',
|
||||
'utils/settings.py',
|
||||
'requirements.txt'
|
||||
]
|
||||
|
||||
for file in required_files:
|
||||
if os.path.exists(file):
|
||||
requirements.append(f"✅ {file}")
|
||||
else:
|
||||
requirements.append(f"❌ {file} fehlt")
|
||||
|
||||
# Konsolidierte Modi-Konfiguration prüfen
|
||||
try:
|
||||
from app import ProductionConfig, DevelopmentConfig
|
||||
requirements.append("✅ Konsolidierte Modi-Konfiguration verfügbar")
|
||||
requirements.append(f" • DevelopmentConfig: Debug + Flexibel")
|
||||
requirements.append(f" • ProductionConfig: Optimiert + Sicher")
|
||||
except ImportError as e:
|
||||
requirements.append(f"❌ Modi-Konfiguration fehlt: {e}")
|
||||
|
||||
# Development-Tools prüfen
|
||||
dev_tools = [
|
||||
'flask',
|
||||
'werkzeug',
|
||||
'jinja2'
|
||||
]
|
||||
|
||||
for tool in dev_tools:
|
||||
try:
|
||||
__import__(tool)
|
||||
requirements.append(f"✅ {tool}")
|
||||
except ImportError:
|
||||
requirements.append(f"❌ {tool} nicht installiert")
|
||||
|
||||
# Datenbank-Verzeichnis prüfen/erstellen
|
||||
if os.path.exists('instance'):
|
||||
requirements.append("✅ Datenbank-Verzeichnis")
|
||||
else:
|
||||
requirements.append("❌ Instance-Verzeichnis fehlt")
|
||||
os.makedirs('instance', exist_ok=True)
|
||||
requirements.append("✅ Instance-Verzeichnis erstellt")
|
||||
|
||||
for req in requirements:
|
||||
print(f" {req}")
|
||||
|
||||
# Kritische Fehler prüfen
|
||||
critical_errors = [r for r in requirements if r.startswith("❌") and "nicht installiert" in r]
|
||||
if critical_errors:
|
||||
print("\n❌ KRITISCHE FEHLER GEFUNDEN:")
|
||||
for error in critical_errors:
|
||||
print(f" {error}")
|
||||
print("\n🛑 Development-Start abgebrochen!")
|
||||
print("💡 Installieren Sie fehlende Pakete: pip install -r requirements.txt")
|
||||
sys.exit(1)
|
||||
|
||||
print("✅ Alle Voraussetzungen erfüllt\n")
|
||||
|
||||
def set_development_optimizations():
|
||||
"""Setzt Development-Optimierungen"""
|
||||
print("🛠️ Aktiviere Development-Optimierungen...")
|
||||
|
||||
# Flask-Development-Einstellungen
|
||||
os.environ['FLASK_DEBUG'] = '1'
|
||||
os.environ['FLASK_RELOAD'] = '1'
|
||||
|
||||
# Asset-Einstellungen (nicht optimiert für Development)
|
||||
os.environ['USE_MINIFIED_ASSETS'] = 'false'
|
||||
os.environ['DISABLE_ANIMATIONS'] = 'false'
|
||||
os.environ['LIMIT_GLASSMORPHISM'] = 'false'
|
||||
|
||||
# Template-Debugging
|
||||
os.environ['TEMPLATES_AUTO_RELOAD'] = 'true'
|
||||
os.environ['EXPLAIN_TEMPLATE_LOADING'] = 'true'
|
||||
|
||||
# JSON-Pretty-Print für Debugging
|
||||
os.environ['JSON_SORT_KEYS'] = 'true'
|
||||
os.environ['JSONIFY_PRETTYPRINT_REGULAR'] = 'true'
|
||||
|
||||
print(" ✅ Flask-Debug-Modus aktiviert")
|
||||
print(" ✅ Auto-Reload aktiviert")
|
||||
print(" ✅ Template-Debugging aktiviert")
|
||||
print(" ✅ Pretty-JSON aktiviert")
|
||||
print()
|
||||
|
||||
def setup_development_security():
|
||||
"""Konfiguriert Development-Sicherheit (relaxed)"""
|
||||
print("🔓 Konfiguriere Development-Sicherheit (relaxed)...")
|
||||
|
||||
# Relaxed Security für Development
|
||||
os.environ['FORCE_HTTPS'] = 'false'
|
||||
os.environ['SESSION_SECURE'] = 'false'
|
||||
os.environ['SESSION_SAMESITE'] = 'Lax'
|
||||
|
||||
# CSRF-Schutz (aber mit längerer Zeit)
|
||||
os.environ['CSRF_TIME_LIMIT'] = '7200' # 2 Stunden
|
||||
|
||||
# Development-spezifische Einstellungen
|
||||
os.environ['COMPLIANCE_MODE'] = 'false'
|
||||
os.environ['AUDIT_LOGGING'] = 'false'
|
||||
|
||||
print(" ✅ HTTP-Modus aktiviert (kein HTTPS erforderlich)")
|
||||
print(" ✅ Relaxed Session-Sicherheit")
|
||||
print(" ✅ Erweiterte CSRF-Zeit (2h)")
|
||||
print(" ✅ Compliance-Modus deaktiviert")
|
||||
print()
|
||||
|
||||
def check_database():
|
||||
"""Prüft und initialisiert die Datenbank"""
|
||||
print("🗄️ Prüfe Datenbank-Status...")
|
||||
|
||||
try:
|
||||
# Prüfe ob Drucker-Management-Script verfügbar ist
|
||||
if os.path.exists('create_correct_printers.py'):
|
||||
print(" ✅ Drucker-Management-Script verfügbar")
|
||||
|
||||
# Prüfe Drucker-Status
|
||||
from create_correct_printers import validate_printers, init_database
|
||||
|
||||
init_database()
|
||||
is_valid = validate_printers()
|
||||
|
||||
if is_valid:
|
||||
print(" ✅ Drucker-Konfiguration ist korrekt")
|
||||
else:
|
||||
print(" ⚠️ Drucker-Konfiguration nicht optimal")
|
||||
print(" 💡 Führen Sie aus: python3.11 create_correct_printers.py reset")
|
||||
else:
|
||||
print(" ⚠️ Drucker-Management-Script nicht gefunden")
|
||||
|
||||
except Exception as e:
|
||||
print(f" ⚠️ Datenbank-Prüfung fehlgeschlagen: {str(e)}")
|
||||
|
||||
print()
|
||||
|
||||
def start_application():
|
||||
"""Startet die Hauptanwendung"""
|
||||
print("🚀 Starte MYP Development System...\n")
|
||||
|
||||
try:
|
||||
# app.py importieren und starten
|
||||
from app import main
|
||||
main()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print("\n🛑 Development-System durch Benutzer gestoppt")
|
||||
except Exception as e:
|
||||
print(f"\n❌ KRITISCHER FEHLER: {str(e)}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
sys.exit(1)
|
||||
|
||||
def main():
|
||||
"""Haupt-Development-Start-Funktion"""
|
||||
# Banner anzeigen
|
||||
print_development_banner()
|
||||
|
||||
# Voraussetzungen prüfen
|
||||
check_development_requirements()
|
||||
|
||||
# Optimierungen setzen
|
||||
set_development_optimizations()
|
||||
|
||||
# Sicherheit konfigurieren
|
||||
setup_development_security()
|
||||
|
||||
# Datenbank prüfen
|
||||
check_database()
|
||||
|
||||
# Anwendung starten
|
||||
start_application()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user