🎉 Verbesserte Backend-Funktionalität durch Windows-sichere Disk-Usage-Bestimmung, Uptime-Berechnung und Einführung eines Kiosk-Timers. Dokumentation aktualisiert und nicht mehr benötigte Dateien entfernt. 🧹

This commit is contained in:
2025-06-01 03:00:04 +02:00
parent 486647fade
commit 8969cf6df6
70 changed files with 89065 additions and 85009 deletions

View File

@@ -6321,14 +6321,53 @@ def api_admin_stats_live():
cpu_percent = psutil.cpu_percent(interval=1)
memory_percent = psutil.virtual_memory().percent
# Disk-Pfad sicher bestimmen
disk_path = '/' if os.name != 'nt' else 'C:\\'
disk_percent = psutil.disk_usage(disk_path).percent
# Windows-sichere Disk-Usage-Bestimmung
disk_percent = 0.0
try:
if os.name == 'nt': # Windows
# Windows: Verwende sicheren Pfad-Ansatz
import string
# Versuche verschiedene Windows-Laufwerke
drives_to_check = ['C:', 'D:', 'E:']
for drive in drives_to_check:
try:
# Prüfe ob Laufwerk existiert
if os.path.exists(drive + '\\'):
disk_usage = psutil.disk_usage(drive + '\\')
disk_percent = disk_usage.percent
break
except (OSError, SystemError) as drive_error:
app_logger.debug(f"Laufwerk {drive} nicht verfügbar: {str(drive_error)}")
continue
# Fallback: Verwende os.statvfs alternative
if disk_percent == 0.0:
try:
import shutil
total, used, free = shutil.disk_usage('C:\\')
disk_percent = (used / total) * 100.0
except Exception as shutil_error:
app_logger.debug(f"Shutil disk_usage fehlgeschlagen: {str(shutil_error)}")
disk_percent = 0.0
else: # Unix/Linux
# Unix: Standard-Pfad verwenden
disk_percent = psutil.disk_usage('/').percent
except Exception as disk_error:
app_logger.warning(f"Disk-Usage-Bestimmung fehlgeschlagen: {str(disk_error)}")
disk_percent = 0.0
# Uptime sicher berechnen
boot_time = psutil.boot_time()
current_time = time.time()
uptime_seconds = int(current_time - boot_time)
try:
boot_time = psutil.boot_time()
current_time = time.time()
uptime_seconds = int(current_time - boot_time)
except Exception as uptime_error:
app_logger.debug(f"Uptime-Berechnung fehlgeschlagen: {str(uptime_error)}")
uptime_seconds = 0
stats['system'] = {
'cpu_percent': float(cpu_percent),