📚 Improved configuration files & documentation 📚

This commit is contained in:
2025-06-01 02:18:16 +02:00
parent 47d0e291fb
commit 5aa7da2aa9
13 changed files with 316 additions and 60 deletions

View File

@ -30,40 +30,47 @@ def test_database_connection():
log_message("Teste Datenbankverbindung...")
try:
# Versuche SQLite-Datenbank zu öffnen
db_files = ['database.db', 'app.db', 'myp.db']
# Pfad zur App hinzufügen für korrekten Import
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
for db_file in db_files:
if os.path.exists(db_file):
log_message(f"Gefundene Datenbankdatei: {db_file}")
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
# Prüfe ob Printer-Tabelle existiert
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='printer';")
if cursor.fetchone():
log_message("✅ Printer-Tabelle gefunden")
# Zähle Drucker
cursor.execute("SELECT COUNT(*) FROM printer;")
count = cursor.fetchone()[0]
log_message(f"📊 Anzahl Drucker in Datenbank: {count}")
# Zeige Drucker-Details
cursor.execute("SELECT id, name, plug_ip, status FROM printer;")
printers = cursor.fetchall()
for printer in printers:
log_message(f" Drucker {printer[0]}: {printer[1]} ({printer[2]}) - Status: {printer[3]}")
conn.close()
return True
else:
log_message("❌ Printer-Tabelle nicht gefunden")
conn.close()
try:
from config.settings import DATABASE_PATH
db_file = DATABASE_PATH
except ImportError:
# Fallback für lokale Ausführung
db_file = os.path.join('database', 'myp.db')
if os.path.exists(db_file):
log_message(f"Gefundene Datenbankdatei: {db_file}")
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
# Prüfe ob Printers-Tabelle existiert
cursor.execute("SELECT name FROM sqlite_master WHERE type='table' AND name='printers';")
if cursor.fetchone():
log_message("✅ Printers-Tabelle gefunden")
# Zähle Drucker
cursor.execute("SELECT COUNT(*) FROM printers;")
count = cursor.fetchone()[0]
log_message(f"📊 Anzahl Drucker in Datenbank: {count}")
# Zeige Drucker-Details
cursor.execute("SELECT id, name, plug_ip, status FROM printers;")
printers = cursor.fetchall()
for printer in printers:
log_message(f" Drucker {printer[0]}: {printer[1]} ({printer[2]}) - Status: {printer[3]}")
conn.close()
return True
else:
log_message("❌ Printers-Tabelle nicht gefunden")
conn.close()
else:
log_message(f"❌ Datenbankdatei nicht gefunden: {db_file}")
log_message("❌ Keine gültige Datenbank gefunden")
return False
except Exception as e:
@ -125,17 +132,21 @@ def test_network_connectivity():
# Lade Drucker aus Datenbank
try:
db_files = ['database.db', 'app.db', 'myp.db']
# Verwende konfigurierten Datenbankpfad
try:
from config.settings import DATABASE_PATH
db_file = DATABASE_PATH
except ImportError:
db_file = os.path.join('database', 'myp.db')
printers = []
for db_file in db_files:
if os.path.exists(db_file):
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("SELECT name, plug_ip FROM printer WHERE plug_ip IS NOT NULL;")
printers = cursor.fetchall()
conn.close()
break
if os.path.exists(db_file):
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("SELECT name, plug_ip FROM printers WHERE plug_ip IS NOT NULL;")
printers = cursor.fetchall()
conn.close()
if not printers:
log_message("❌ Keine Drucker mit IP-Adressen gefunden")
@ -194,17 +205,21 @@ def test_tapo_connections():
# Lade Drucker aus Datenbank
try:
db_files = ['database.db', 'app.db', 'myp.db']
# Verwende konfigurierten Datenbankpfad
try:
from config.settings import DATABASE_PATH
db_file = DATABASE_PATH
except ImportError:
db_file = os.path.join('database', 'myp.db')
printers = []
for db_file in db_files:
if os.path.exists(db_file):
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("SELECT id, name, plug_ip, plug_username, plug_password FROM printer WHERE plug_ip IS NOT NULL;")
printers = cursor.fetchall()
conn.close()
break
if os.path.exists(db_file):
conn = sqlite3.connect(db_file)
cursor = conn.cursor()
cursor.execute("SELECT id, name, plug_ip, plug_username, plug_password FROM printers WHERE plug_ip IS NOT NULL;")
printers = cursor.fetchall()
conn.close()
if not printers:
log_message("❌ Keine Drucker mit Tapo-Konfiguration gefunden")