99 lines
3.0 KiB
Python
99 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
||
"""
|
||
Script zum Erstellen von Test-Druckern für die MYP Plattform
|
||
"""
|
||
|
||
import sys
|
||
import os
|
||
sys.path.append('.')
|
||
|
||
from models import *
|
||
from datetime import datetime
|
||
|
||
def create_test_printers():
|
||
"""Erstellt Test-Drucker in der Datenbank."""
|
||
|
||
# Verbindung zur Datenbank
|
||
db_session = get_db_session()
|
||
|
||
# Test-Drucker Daten
|
||
test_printers = [
|
||
{
|
||
'name': 'Ultimaker S3 #01',
|
||
'model': 'Ultimaker S3',
|
||
'location': 'Produktionshalle A',
|
||
'plug_ip': '192.168.1.100',
|
||
'status': 'available',
|
||
'active': True
|
||
},
|
||
{
|
||
'name': 'Prusa MK3S+ #02',
|
||
'model': 'Prusa MK3S+',
|
||
'location': 'Produktionshalle B',
|
||
'plug_ip': '192.168.1.101',
|
||
'status': 'offline',
|
||
'active': True
|
||
},
|
||
{
|
||
'name': 'Bambu Lab X1 #03',
|
||
'model': 'Bambu Lab X1 Carbon',
|
||
'location': 'Labor R&D',
|
||
'plug_ip': '192.168.1.102',
|
||
'status': 'available',
|
||
'active': True
|
||
},
|
||
{
|
||
'name': 'Formlabs Form 3 #04',
|
||
'model': 'Formlabs Form 3',
|
||
'location': 'Prototyping Lab',
|
||
'plug_ip': '192.168.1.103',
|
||
'status': 'maintenance',
|
||
'active': False
|
||
},
|
||
{
|
||
'name': 'Ender 3 V2 #05',
|
||
'model': 'Creality Ender 3 V2',
|
||
'location': 'Testbereich',
|
||
'plug_ip': '192.168.1.104',
|
||
'status': 'offline',
|
||
'active': True
|
||
}
|
||
]
|
||
|
||
try:
|
||
created_count = 0
|
||
for printer_data in test_printers:
|
||
# Prüfen ob Drucker bereits existiert
|
||
existing = db_session.query(Printer).filter_by(name=printer_data['name']).first()
|
||
if not existing:
|
||
printer = Printer(
|
||
name=printer_data['name'],
|
||
model=printer_data['model'],
|
||
location=printer_data['location'],
|
||
plug_ip=printer_data['plug_ip'],
|
||
status=printer_data['status'],
|
||
active=printer_data['active'],
|
||
created_at=datetime.now()
|
||
)
|
||
db_session.add(printer)
|
||
created_count += 1
|
||
print(f"✅ Drucker '{printer_data['name']}' erstellt")
|
||
else:
|
||
print(f"ℹ️ Drucker '{printer_data['name']}' existiert bereits")
|
||
|
||
db_session.commit()
|
||
|
||
total_count = db_session.query(Printer).count()
|
||
print(f"\n🎉 {created_count} neue Test-Drucker erstellt!")
|
||
print(f"📊 Insgesamt {total_count} Drucker in der Datenbank.")
|
||
|
||
except Exception as e:
|
||
print(f"❌ Fehler beim Erstellen der Test-Drucker: {str(e)}")
|
||
db_session.rollback()
|
||
finally:
|
||
db_session.close()
|
||
|
||
if __name__ == "__main__":
|
||
print("🚀 Erstelle Test-Drucker für MYP Plattform...")
|
||
create_test_printers()
|
||
print("✅ Fertig!") |