It appears that the repository has undergone several changes and renamings:
This commit is contained in:
95
backend/setup/create_test_tapo_printers.py
Normal file
95
backend/setup/create_test_tapo_printers.py
Normal file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python3.11
|
||||
"""
|
||||
Script zum Erstellen von Test-Druckern mit Tapo-Steckdosen
|
||||
"""
|
||||
|
||||
from models import get_db_session, Printer
|
||||
from datetime import datetime
|
||||
|
||||
def create_test_printers():
|
||||
"""Erstellt Test-Drucker mit Tapo-Steckdosen."""
|
||||
db = get_db_session()
|
||||
|
||||
# Test-Drucker mit Tapo-Steckdosen
|
||||
test_printers = [
|
||||
{
|
||||
'name': 'Ender 3 Pro',
|
||||
'ip': '192.168.0.100',
|
||||
'plug_ip': '192.168.0.103',
|
||||
'location': 'Werkstatt A',
|
||||
'description': 'Creality Ender 3 Pro - Einsteigermodell'
|
||||
},
|
||||
{
|
||||
'name': 'Prusa i3 MK3S',
|
||||
'ip': '192.168.0.101',
|
||||
'plug_ip': '192.168.0.104',
|
||||
'location': 'Werkstatt B',
|
||||
'description': 'Prusa i3 MK3S+ - Profi-Drucker'
|
||||
},
|
||||
{
|
||||
'name': 'Artillery Sidewinder',
|
||||
'ip': '192.168.0.102',
|
||||
'plug_ip': '192.168.0.100',
|
||||
'location': 'Labor',
|
||||
'description': 'Artillery Sidewinder X1 - Großformat'
|
||||
},
|
||||
{
|
||||
'name': 'Bambu Lab A1 mini',
|
||||
'ip': '192.168.0.105',
|
||||
'plug_ip': '192.168.0.101',
|
||||
'location': 'Entwicklung',
|
||||
'description': 'Bambu Lab A1 mini - Kompakt und schnell'
|
||||
},
|
||||
{
|
||||
'name': 'Ultimaker S3',
|
||||
'ip': '192.168.0.106',
|
||||
'plug_ip': '192.168.0.102',
|
||||
'location': 'Prototyping',
|
||||
'description': 'Ultimaker S3 - Dual-Extruder'
|
||||
}
|
||||
]
|
||||
|
||||
created_count = 0
|
||||
updated_count = 0
|
||||
|
||||
for printer_data in test_printers:
|
||||
existing = db.query(Printer).filter_by(name=printer_data['name']).first()
|
||||
|
||||
if not existing:
|
||||
printer = Printer(
|
||||
name=printer_data['name'],
|
||||
ip=printer_data['ip'],
|
||||
plug_ip=printer_data['plug_ip'],
|
||||
location=printer_data['location'],
|
||||
description=printer_data['description'],
|
||||
active=True,
|
||||
created_at=datetime.now()
|
||||
)
|
||||
db.add(printer)
|
||||
created_count += 1
|
||||
print(f"✅ Erstellt: {printer_data['name']} mit Tapo {printer_data['plug_ip']}")
|
||||
else:
|
||||
existing.plug_ip = printer_data['plug_ip']
|
||||
existing.location = printer_data['location']
|
||||
existing.description = printer_data['description']
|
||||
existing.active = True
|
||||
updated_count += 1
|
||||
print(f"🔄 Aktualisiert: {printer_data['name']} mit Tapo {printer_data['plug_ip']}")
|
||||
|
||||
try:
|
||||
db.commit()
|
||||
print(f"\n🎯 Erfolgreich abgeschlossen:")
|
||||
print(f" - {created_count} neue Drucker erstellt")
|
||||
print(f" - {updated_count} Drucker aktualisiert")
|
||||
print(f" - Gesamt: {created_count + updated_count} Drucker mit Tapo-Steckdosen")
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
print(f"❌ Fehler beim Speichern: {e}")
|
||||
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("🔧 Erstelle Test-Drucker mit Tapo-Steckdosen...")
|
||||
create_test_printers()
|
Reference in New Issue
Block a user