🎉 Improved Blueprints for Kiosk Mode & Production Readiness 🖱️
This commit is contained in:
@ -182,10 +182,14 @@ def restart_system():
|
|||||||
def delayed_restart():
|
def delayed_restart():
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
try:
|
try:
|
||||||
|
from utils.core_system import safe_subprocess_run
|
||||||
if os.name == 'nt': # Windows
|
if os.name == 'nt': # Windows
|
||||||
subprocess.run(["shutdown", "/r", "/t", "0"], check=True)
|
result = safe_subprocess_run(["shutdown", "/r", "/t", "0"], timeout=10)
|
||||||
else: # Linux/Unix
|
else: # Linux/Unix
|
||||||
subprocess.run(["sudo", "reboot"], check=True)
|
result = safe_subprocess_run(["sudo", "reboot"], timeout=10)
|
||||||
|
|
||||||
|
if not result or result.returncode != 0:
|
||||||
|
kiosk_logger.error("System-Neustart-Befehl fehlgeschlagen")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
kiosk_logger.error(f"Fehler beim System-Neustart: {str(e)}")
|
kiosk_logger.error(f"Fehler beim System-Neustart: {str(e)}")
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
Production-Startskript für Mercedes-Benz TBA Marienfelde
|
Production-Startskript für Mercedes-Benz TBA Marienfelde
|
||||||
|
@ -329,23 +329,23 @@ class ErrorRecoverySystem:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# Service-Status prüfen
|
# Service-Status prüfen
|
||||||
result = subprocess.run(
|
result = safe_subprocess_run(
|
||||||
["systemctl", "is-active", service_name],
|
["systemctl", "is-active", service_name],
|
||||||
capture_output=True, text=True, timeout=10
|
capture_output=True, timeout=10
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
recovery_logger.info(f"✅ Service {service_name} ist bereits aktiv")
|
recovery_logger.info(f"✅ Service {service_name} ist bereits aktiv")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Service neustarten
|
# Service neustarten
|
||||||
recovery_logger.info(f"🔄 Starte Service {service_name} neu...")
|
recovery_logger.info(f"🔄 Starte Service {service_name} neu...")
|
||||||
result = subprocess.run(
|
result = safe_subprocess_run(
|
||||||
["systemctl", "restart", service_name],
|
["systemctl", "restart", service_name],
|
||||||
capture_output=True, text=True, timeout=30
|
capture_output=True, timeout=30
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
recovery_logger.info(f"✅ Service {service_name} erfolgreich neugestartet")
|
recovery_logger.info(f"✅ Service {service_name} erfolgreich neugestartet")
|
||||||
|
|
||||||
# Recovery-Historie aktualisieren
|
# Recovery-Historie aktualisieren
|
||||||
@ -598,11 +598,11 @@ class WatchdogManager:
|
|||||||
def is_service_active(self, service_name: str) -> bool:
|
def is_service_active(self, service_name: str) -> bool:
|
||||||
"""Prüft ob Service aktiv ist"""
|
"""Prüft ob Service aktiv ist"""
|
||||||
try:
|
try:
|
||||||
result = subprocess.run(
|
result = safe_subprocess_run(
|
||||||
["systemctl", "is-active", "--quiet", service_name],
|
["systemctl", "is-active", "--quiet", service_name],
|
||||||
capture_output=True
|
capture_output=True, timeout=5
|
||||||
)
|
)
|
||||||
return result.returncode == 0
|
return result and result.returncode == 0
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -626,12 +626,12 @@ class WatchdogManager:
|
|||||||
try:
|
try:
|
||||||
watchdog_logger.info(f"Starte Service neu: {service_name} (Versuch {restart_count + 1}/{max_attempts})")
|
watchdog_logger.info(f"Starte Service neu: {service_name} (Versuch {restart_count + 1}/{max_attempts})")
|
||||||
|
|
||||||
result = subprocess.run(
|
result = safe_subprocess_run(
|
||||||
["systemctl", "restart", service_name],
|
["systemctl", "restart", service_name],
|
||||||
capture_output=True, text=True, timeout=30
|
capture_output=True, timeout=30
|
||||||
)
|
)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
self.restart_counts[service_name] = restart_count + 1
|
self.restart_counts[service_name] = restart_count + 1
|
||||||
self.last_restart_times[service_name] = now
|
self.last_restart_times[service_name] = now
|
||||||
time.sleep(self.config.get("restart_delay", 15))
|
time.sleep(self.config.get("restart_delay", 15))
|
||||||
@ -711,10 +711,10 @@ class WatchdogManager:
|
|||||||
|
|
||||||
for cache_dir in cache_dirs:
|
for cache_dir in cache_dirs:
|
||||||
if os.path.exists(cache_dir):
|
if os.path.exists(cache_dir):
|
||||||
subprocess.run(["rm", "-rf", f"{cache_dir}/*"], shell=True)
|
safe_subprocess_run(["rm", "-rf", f"{cache_dir}/*"], shell=True, timeout=30)
|
||||||
|
|
||||||
# System-Cache leeren
|
# System-Cache leeren
|
||||||
subprocess.run(["sync"])
|
safe_subprocess_run(["sync"], timeout=10)
|
||||||
with open("/proc/sys/vm/drop_caches", "w") as f:
|
with open("/proc/sys/vm/drop_caches", "w") as f:
|
||||||
f.write("3")
|
f.write("3")
|
||||||
|
|
||||||
|
@ -202,6 +202,7 @@ class SafeFileHandler:
|
|||||||
def _move_to_trash_windows(self, file_path: Path) -> bool:
|
def _move_to_trash_windows(self, file_path: Path) -> bool:
|
||||||
"""Windows-spezifische Papierkorb-Implementation"""
|
"""Windows-spezifische Papierkorb-Implementation"""
|
||||||
try:
|
try:
|
||||||
|
from utils.core_system import safe_subprocess_run
|
||||||
cmd = [
|
cmd = [
|
||||||
'powershell', '-Command',
|
'powershell', '-Command',
|
||||||
f'Add-Type -AssemblyName Microsoft.VisualBasic; '
|
f'Add-Type -AssemblyName Microsoft.VisualBasic; '
|
||||||
@ -209,13 +210,14 @@ class SafeFileHandler:
|
|||||||
f'"OnlyErrorDialogs", "SendToRecycleBin")'
|
f'"OnlyErrorDialogs", "SendToRecycleBin")'
|
||||||
]
|
]
|
||||||
|
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
result = safe_subprocess_run(cmd, capture_output=True, timeout=30)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
data_logger.info(f"Datei erfolgreich in Papierkorb verschoben: {file_path}")
|
data_logger.info(f"Datei erfolgreich in Papierkorb verschoben: {file_path}")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
data_logger.error(f"PowerShell-Fehler: {result.stderr}")
|
error_msg = result.stderr if result else "Unbekannter Fehler"
|
||||||
|
data_logger.error(f"PowerShell-Fehler: {error_msg}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -225,6 +227,7 @@ class SafeFileHandler:
|
|||||||
def _move_to_trash_unix(self, file_path: Path) -> bool:
|
def _move_to_trash_unix(self, file_path: Path) -> bool:
|
||||||
"""Unix-spezifische Papierkorb-Implementation"""
|
"""Unix-spezifische Papierkorb-Implementation"""
|
||||||
try:
|
try:
|
||||||
|
from utils.core_system import safe_subprocess_run
|
||||||
tools = ['gio', 'gvfs-trash', 'trash-put']
|
tools = ['gio', 'gvfs-trash', 'trash-put']
|
||||||
|
|
||||||
for tool in tools:
|
for tool in tools:
|
||||||
@ -236,9 +239,9 @@ class SafeFileHandler:
|
|||||||
elif tool == 'trash-put':
|
elif tool == 'trash-put':
|
||||||
cmd = ['trash-put', str(file_path)]
|
cmd = ['trash-put', str(file_path)]
|
||||||
|
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
result = safe_subprocess_run(cmd, capture_output=True, timeout=10)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
data_logger.info(f"Datei erfolgreich in Papierkorb verschoben ({tool}): {file_path}")
|
data_logger.info(f"Datei erfolgreich in Papierkorb verschoben ({tool}): {file_path}")
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -40,13 +40,15 @@ class SSLManager:
|
|||||||
]
|
]
|
||||||
|
|
||||||
# Führe OpenSSL-Befehl aus
|
# Führe OpenSSL-Befehl aus
|
||||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
from utils.core_system import safe_subprocess_run
|
||||||
|
result = safe_subprocess_run(cmd, capture_output=True, timeout=30)
|
||||||
|
|
||||||
if result.returncode == 0:
|
if result and result.returncode == 0:
|
||||||
logger.info(f"✅ SSL-Zertifikat erfolgreich erstellt: {self.cert_path}")
|
logger.info(f"✅ SSL-Zertifikat erfolgreich erstellt: {self.cert_path}")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
logger.error(f"❌ Fehler beim Erstellen des SSL-Zertifikats: {result.stderr}")
|
error_msg = result.stderr if result else "Unbekannter Fehler"
|
||||||
|
logger.error(f"❌ Fehler beim Erstellen des SSL-Zertifikats: {error_msg}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
|
Reference in New Issue
Block a user