📚 Improved documentation for TAPO issue resolution in backend/TAPO_PROBLEMBEHEBUNG.md
This commit is contained in:
91
backend/install_pyp100.py
Normal file
91
backend/install_pyp100.py
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
PyP100 Installation Script für MYP
|
||||
Installiert das PyP100-Modul für TP-Link Tapo P100/P110 Steckdosen
|
||||
"""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
def install_pyp100():
|
||||
"""Installiert PyP100 über pip"""
|
||||
try:
|
||||
print("🔧 Installiere PyP100-Modul...")
|
||||
|
||||
# PyP100 installieren
|
||||
result = subprocess.run([
|
||||
sys.executable, "-m", "pip", "install", "PyP100"
|
||||
], capture_output=True, text=True, timeout=120)
|
||||
|
||||
if result.returncode == 0:
|
||||
print("✅ PyP100 erfolgreich installiert!")
|
||||
print(f"Output: {result.stdout}")
|
||||
return True
|
||||
else:
|
||||
print("❌ Fehler bei der PyP100-Installation:")
|
||||
print(f"Error: {result.stderr}")
|
||||
return False
|
||||
|
||||
except subprocess.TimeoutExpired:
|
||||
print("❌ Installation-Timeout - PyP100-Installation dauerte zu lange")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"❌ Unerwarteter Fehler bei PyP100-Installation: {e}")
|
||||
return False
|
||||
|
||||
def test_pyp100_import():
|
||||
"""Testet ob PyP100 korrekt importiert werden kann"""
|
||||
try:
|
||||
import PyP100
|
||||
print("✅ PyP100-Import erfolgreich!")
|
||||
return True
|
||||
except ImportError as e:
|
||||
print(f"❌ PyP100-Import fehlgeschlagen: {e}")
|
||||
return False
|
||||
|
||||
def main():
|
||||
"""Haupt-Installationsroutine"""
|
||||
print("🚀 MYP PyP100-Installationsskript")
|
||||
print("=" * 40)
|
||||
|
||||
# Prüfe zunächst, ob PyP100 bereits verfügbar ist
|
||||
if test_pyp100_import():
|
||||
print("ℹ️ PyP100 ist bereits installiert - keine Aktion erforderlich")
|
||||
return True
|
||||
|
||||
# Installiere PyP100
|
||||
if install_pyp100():
|
||||
# Teste nach Installation
|
||||
if test_pyp100_import():
|
||||
print("🎉 PyP100 erfolgreich installiert und getestet!")
|
||||
return True
|
||||
else:
|
||||
print("❌ PyP100 installiert, aber Import-Test fehlgeschlagen")
|
||||
return False
|
||||
else:
|
||||
print("❌ PyP100-Installation fehlgeschlagen")
|
||||
|
||||
# Alternative Installation versuchen
|
||||
print("🔄 Versuche alternative Installation...")
|
||||
try:
|
||||
result = subprocess.run([
|
||||
sys.executable, "-m", "pip", "install", "--user", "PyP100"
|
||||
], capture_output=True, text=True, timeout=120)
|
||||
|
||||
if result.returncode == 0:
|
||||
print("✅ Alternative PyP100-Installation erfolgreich!")
|
||||
if test_pyp100_import():
|
||||
print("🎉 PyP100 erfolgreich installiert und getestet!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Auch alternative Installation fehlgeschlagen")
|
||||
|
||||
except Exception as e:
|
||||
print(f"❌ Alternative Installation fehlgeschlagen: {e}")
|
||||
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = main()
|
||||
sys.exit(0 if success else 1)
|
Reference in New Issue
Block a user