📚 Improved code organization and structure in backend modules 🚧🔧

This commit is contained in:
2025-06-11 14:20:21 +02:00
parent c4bd6ff4dc
commit c386b34d3a
10 changed files with 42 additions and 13 deletions

View File

@@ -45,7 +45,7 @@ class FileManager:
def __init__(self, base_upload_folder: str = None):
try:
from utils.settings import UPLOAD_FOLDER, ALLOWED_EXTENSIONS
from utils.utilities_collection import UPLOAD_FOLDER, ALLOWED_EXTENSIONS
self.base_folder = base_upload_folder or UPLOAD_FOLDER
self.allowed_extensions = ALLOWED_EXTENSIONS
except ImportError:

View File

@@ -23,7 +23,7 @@ from flask_login import current_user
from utils.logging_config import get_logger
from models import Job, Printer, JobOrder, get_db_session
from utils.data_management import save_job_file, save_temp_file
from utils.settings import ALLOWED_EXTENSIONS, MAX_FILE_SIZE, UPLOAD_FOLDER
from utils.utilities_collection import ALLOWED_EXTENSIONS, MAX_FILE_SIZE, UPLOAD_FOLDER
logger = get_logger("drag_drop")

View File

@@ -71,7 +71,7 @@ class TapoController:
"""Initialisiere den Tapo Controller"""
# Lazy import um zirkuläre Abhängigkeiten zu vermeiden
try:
from utils.settings import TAPO_USERNAME, TAPO_PASSWORD, DEFAULT_TAPO_IPS, TAPO_TIMEOUT, TAPO_RETRY_COUNT
from utils.utilities_collection import TAPO_USERNAME, TAPO_PASSWORD, DEFAULT_TAPO_IPS, TAPO_TIMEOUT, TAPO_RETRY_COUNT
self.username = TAPO_USERNAME
self.password = TAPO_PASSWORD
self.default_ips = DEFAULT_TAPO_IPS

View File

@@ -9,7 +9,7 @@ from sqlalchemy.orm import joinedload
from utils.logging_config import get_logger
from models import Job, Printer, get_db_session
from utils.settings import TAPO_USERNAME, TAPO_PASSWORD
from utils.utilities_collection import TAPO_USERNAME, TAPO_PASSWORD
from utils.hardware_integration import tapo_controller
# Legacy function - use tapo_controller.test_connection instead
def test_tapo_connection(*args, **kwargs):

View File

@@ -38,6 +38,21 @@ class Config:
SESSION_LIFETIME = 3600
MAX_FILE_SIZE = 100 * 1024 * 1024 # 100MB
ALLOWED_EXTENSIONS = ['.gcode', '.stl', '.obj']
UPLOAD_FOLDER = "backend/uploads"
# TAPO Smart Plug Configuration
TAPO_USERNAME = "till.tomczak@mercedes-benz.com"
TAPO_PASSWORD = "744563017196A"
DEFAULT_TAPO_IPS = [
"192.168.0.103",
"192.168.0.104",
"192.168.0.100",
"192.168.0.101",
"192.168.0.102",
"192.168.0.105"
]
TAPO_TIMEOUT = 10
TAPO_RETRY_COUNT = 3
@classmethod
def get_all(cls) -> Dict[str, Any]:
@@ -215,6 +230,20 @@ def get_system_status() -> Dict[str, Any]:
DATABASE_PATH = Config.DATABASE_PATH
SECRET_KEY = Config.SECRET_KEY
SESSION_LIFETIME = Config.SESSION_LIFETIME
UPLOAD_FOLDER = Config.UPLOAD_FOLDER
ALLOWED_EXTENSIONS = Config.ALLOWED_EXTENSIONS
MAX_FILE_SIZE = Config.MAX_FILE_SIZE
TAPO_USERNAME = Config.TAPO_USERNAME
TAPO_PASSWORD = Config.TAPO_PASSWORD
DEFAULT_TAPO_IPS = Config.DEFAULT_TAPO_IPS
TAPO_TIMEOUT = Config.TAPO_TIMEOUT
TAPO_RETRY_COUNT = Config.TAPO_RETRY_COUNT
def ensure_database_directory():
"""Erstellt das Datenbank-Verzeichnis."""
db_dir = os.path.dirname(DATABASE_PATH)
if db_dir:
os.makedirs(db_dir, exist_ok=True)
def send_email(recipient, subject, message):
return email_notification.send_notification(recipient, subject, message)