📚 Reorganized documentation files and renamed for clarity

This commit is contained in:
Till Tomczak
2025-06-20 08:56:51 +02:00
parent e0eab2b6b1
commit 98f7878351
38 changed files with 2775 additions and 51 deletions

View File

@ -201,28 +201,53 @@ def fix_windows_socket_issues():
windows_logger.warning(f"⚠️ Socket-Optimierungen konnten nicht angewendet werden: {e}")
def safe_subprocess_run(*args, **kwargs):
"""Sicherer subprocess.run Wrapper für Windows mit UTF-8 Encoding"""
"""Sicherer subprocess.run Wrapper mit robustem UTF-8 Encoding"""
import subprocess
if 'encoding' not in kwargs and kwargs.get('text', False):
kwargs['encoding'] = 'utf-8'
kwargs['errors'] = 'replace'
# Standardwerte für sichere Text-Verarbeitung
default_kwargs = {
'encoding': 'utf-8',
'errors': 'replace', # Ersetzt ungültige Zeichen statt Fehler
'timeout': 30,
'text': True
}
if 'timeout' not in kwargs:
kwargs['timeout'] = 30
# Angegebene kwargs haben Vorrang
for key, value in default_kwargs.items():
if key not in kwargs:
kwargs[key] = value
try:
return subprocess.run(*args, **kwargs)
except subprocess.TimeoutExpired as e:
windows_logger.warning(f"Subprocess-Timeout: {args}")
windows_logger.warning(f"Subprocess-Timeout: {args[0] if args else 'unknown'}")
raise e
except UnicodeDecodeError as e:
windows_logger.error(f"Unicode-Decode-Fehler: {e}")
kwargs_fallback = kwargs.copy()
kwargs_fallback.pop('text', None)
kwargs_fallback.pop('encoding', None)
kwargs_fallback.pop('errors', None)
return subprocess.run(*args, **kwargs_fallback)
# Robuster Fallback: Binary Mode
fallback_kwargs = {
'timeout': kwargs.get('timeout', 30),
'capture_output': kwargs.get('capture_output', False),
'check': kwargs.get('check', False)
}
result = subprocess.run(*args, **fallback_kwargs)
# Manuelle UTF-8 Dekodierung mit Error-Handling
if hasattr(result, 'stdout') and result.stdout:
try:
result.stdout = result.stdout.decode('utf-8', errors='replace')
except (AttributeError, UnicodeDecodeError):
pass # Bereits string oder nicht dekodierbar
if hasattr(result, 'stderr') and result.stderr:
try:
result.stderr = result.stderr.decode('utf-8', errors='replace')
except (AttributeError, UnicodeDecodeError):
pass # Bereits string oder nicht dekodierbar
return result
except Exception as e:
windows_logger.error(f"Subprocess-Fehler: {e}")
raise e
def apply_all_windows_fixes():
"""Wendet alle Windows-spezifischen Fixes an"""