Files
Projektarbeit-MYP/backend/install_pyp100.py

91 lines
2.9 KiB
Python
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/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)