📚 Improved code organization and structure in backend modules 🚧🔧
This commit is contained in:
@ -246,7 +246,7 @@ def get_environment_type():
|
|||||||
# Windows-spezifische Fixes
|
# Windows-spezifische Fixes
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
try:
|
try:
|
||||||
from utils.windows_fixes import get_windows_thread_manager
|
from utils.core_system import get_windows_thread_manager
|
||||||
print("[OK] Windows-Fixes (sichere Version) geladen")
|
print("[OK] Windows-Fixes (sichere Version) geladen")
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
get_windows_thread_manager = None
|
get_windows_thread_manager = None
|
||||||
@ -259,7 +259,7 @@ from models import init_database, create_initial_admin, User, get_db_session
|
|||||||
from utils.logging_config import setup_logging, get_logger, log_startup_info
|
from utils.logging_config import setup_logging, get_logger, log_startup_info
|
||||||
from utils.job_scheduler import JobScheduler, get_job_scheduler
|
from utils.job_scheduler import JobScheduler, get_job_scheduler
|
||||||
from utils.queue_manager import start_queue_manager, stop_queue_manager
|
from utils.queue_manager import start_queue_manager, stop_queue_manager
|
||||||
from utils.settings import SECRET_KEY, SESSION_LIFETIME
|
from utils.utilities_collection import SECRET_KEY, SESSION_LIFETIME
|
||||||
|
|
||||||
# Blueprints importieren
|
# Blueprints importieren
|
||||||
from blueprints.auth import auth_blueprint
|
from blueprints.auth import auth_blueprint
|
||||||
@ -377,7 +377,7 @@ def apply_production_config(app):
|
|||||||
app_logger.info("[PRODUCTION] Aktiviere Production-Konfiguration für Mercedes-Benz TBA")
|
app_logger.info("[PRODUCTION] Aktiviere Production-Konfiguration für Mercedes-Benz TBA")
|
||||||
|
|
||||||
# Dynamische Werte setzen
|
# Dynamische Werte setzen
|
||||||
from utils.settings import SECRET_KEY, SESSION_LIFETIME
|
from utils.utilities_collection import SECRET_KEY, SESSION_LIFETIME
|
||||||
ProductionConfig.SECRET_KEY = os.environ.get('SECRET_KEY') or SECRET_KEY
|
ProductionConfig.SECRET_KEY = os.environ.get('SECRET_KEY') or SECRET_KEY
|
||||||
ProductionConfig.PERMANENT_SESSION_LIFETIME = SESSION_LIFETIME
|
ProductionConfig.PERMANENT_SESSION_LIFETIME = SESSION_LIFETIME
|
||||||
|
|
||||||
@ -431,7 +431,7 @@ def apply_development_config(app):
|
|||||||
app_logger.info("[DEVELOPMENT] Aktiviere Development-Konfiguration")
|
app_logger.info("[DEVELOPMENT] Aktiviere Development-Konfiguration")
|
||||||
|
|
||||||
# Dynamische Werte setzen
|
# Dynamische Werte setzen
|
||||||
from utils.settings import SECRET_KEY, SESSION_LIFETIME
|
from utils.utilities_collection import SECRET_KEY, SESSION_LIFETIME
|
||||||
DevelopmentConfig.SECRET_KEY = os.environ.get('SECRET_KEY') or SECRET_KEY
|
DevelopmentConfig.SECRET_KEY = os.environ.get('SECRET_KEY') or SECRET_KEY
|
||||||
DevelopmentConfig.PERMANENT_SESSION_LIFETIME = SESSION_LIFETIME
|
DevelopmentConfig.PERMANENT_SESSION_LIFETIME = SESSION_LIFETIME
|
||||||
|
|
||||||
|
@ -726,7 +726,7 @@ def create_backup():
|
|||||||
with zipfile.ZipFile(backup_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
with zipfile.ZipFile(backup_path, 'w', zipfile.ZIP_DEFLATED) as zipf:
|
||||||
# 1. Datenbank-Datei hinzufügen
|
# 1. Datenbank-Datei hinzufügen
|
||||||
try:
|
try:
|
||||||
from utils.settings import DATABASE_PATH
|
from utils.utilities_collection import DATABASE_PATH
|
||||||
if os.path.exists(DATABASE_PATH):
|
if os.path.exists(DATABASE_PATH):
|
||||||
zipf.write(DATABASE_PATH, 'database/main.db')
|
zipf.write(DATABASE_PATH, 'database/main.db')
|
||||||
created_files.append('database/main.db')
|
created_files.append('database/main.db')
|
||||||
@ -854,7 +854,7 @@ def optimize_database():
|
|||||||
try:
|
try:
|
||||||
admin_api_logger.info(f"Datenbank-Optimierung angefordert von Admin {current_user.username}")
|
admin_api_logger.info(f"Datenbank-Optimierung angefordert von Admin {current_user.username}")
|
||||||
|
|
||||||
from utils.settings import DATABASE_PATH
|
from utils.utilities_collection import DATABASE_PATH
|
||||||
|
|
||||||
optimization_results = {
|
optimization_results = {
|
||||||
'vacuum_completed': False,
|
'vacuum_completed': False,
|
||||||
|
@ -9,7 +9,7 @@ from flask_login import login_required, current_user
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from models import User, get_db_session, SystemLog
|
from models import User, get_db_session, SystemLog
|
||||||
from utils.logging_config import get_logger
|
from utils.logging_config import get_logger
|
||||||
from utils.settings import SESSION_LIFETIME
|
from utils.utilities_collection import SESSION_LIFETIME
|
||||||
|
|
||||||
# Blueprint erstellen
|
# Blueprint erstellen
|
||||||
sessions_blueprint = Blueprint('sessions', __name__, url_prefix='/api/session')
|
sessions_blueprint = Blueprint('sessions', __name__, url_prefix='/api/session')
|
||||||
|
@ -15,7 +15,7 @@ from datetime import datetime
|
|||||||
from models import get_db_session, SystemLog
|
from models import get_db_session, SystemLog
|
||||||
from utils.logging_config import get_logger
|
from utils.logging_config import get_logger
|
||||||
from utils.data_management import file_manager, save_job_file, save_guest_file, save_avatar_file, save_asset_file, save_log_file, save_backup_file, save_temp_file, delete_file as delete_file_safe
|
from utils.data_management import file_manager, save_job_file, save_guest_file, save_avatar_file, save_asset_file, save_log_file, save_backup_file, save_temp_file, delete_file as delete_file_safe
|
||||||
from utils.settings import UPLOAD_FOLDER, ALLOWED_EXTENSIONS
|
from utils.utilities_collection import UPLOAD_FOLDER, ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
# Blueprint erstellen
|
# Blueprint erstellen
|
||||||
uploads_blueprint = Blueprint('uploads', __name__, url_prefix='/api')
|
uploads_blueprint = Blueprint('uploads', __name__, url_prefix='/api')
|
||||||
|
@ -15,7 +15,7 @@ from flask_login import UserMixin
|
|||||||
import bcrypt
|
import bcrypt
|
||||||
import secrets
|
import secrets
|
||||||
|
|
||||||
from utils.settings import DATABASE_PATH, ensure_database_directory
|
from utils.utilities_collection import DATABASE_PATH, ensure_database_directory
|
||||||
from utils.logging_config import get_logger
|
from utils.logging_config import get_logger
|
||||||
|
|
||||||
# ===== DATABASE CLEANUP INTEGRATION =====
|
# ===== DATABASE CLEANUP INTEGRATION =====
|
||||||
|
@ -45,7 +45,7 @@ class FileManager:
|
|||||||
|
|
||||||
def __init__(self, base_upload_folder: str = None):
|
def __init__(self, base_upload_folder: str = None):
|
||||||
try:
|
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.base_folder = base_upload_folder or UPLOAD_FOLDER
|
||||||
self.allowed_extensions = ALLOWED_EXTENSIONS
|
self.allowed_extensions = ALLOWED_EXTENSIONS
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
@ -23,7 +23,7 @@ from flask_login import current_user
|
|||||||
from utils.logging_config import get_logger
|
from utils.logging_config import get_logger
|
||||||
from models import Job, Printer, JobOrder, get_db_session
|
from models import Job, Printer, JobOrder, get_db_session
|
||||||
from utils.data_management import save_job_file, save_temp_file
|
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")
|
logger = get_logger("drag_drop")
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ class TapoController:
|
|||||||
"""Initialisiere den Tapo Controller"""
|
"""Initialisiere den Tapo Controller"""
|
||||||
# Lazy import um zirkuläre Abhängigkeiten zu vermeiden
|
# Lazy import um zirkuläre Abhängigkeiten zu vermeiden
|
||||||
try:
|
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.username = TAPO_USERNAME
|
||||||
self.password = TAPO_PASSWORD
|
self.password = TAPO_PASSWORD
|
||||||
self.default_ips = DEFAULT_TAPO_IPS
|
self.default_ips = DEFAULT_TAPO_IPS
|
||||||
|
@ -9,7 +9,7 @@ from sqlalchemy.orm import joinedload
|
|||||||
|
|
||||||
from utils.logging_config import get_logger
|
from utils.logging_config import get_logger
|
||||||
from models import Job, Printer, get_db_session
|
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
|
from utils.hardware_integration import tapo_controller
|
||||||
# Legacy function - use tapo_controller.test_connection instead
|
# Legacy function - use tapo_controller.test_connection instead
|
||||||
def test_tapo_connection(*args, **kwargs):
|
def test_tapo_connection(*args, **kwargs):
|
||||||
|
@ -38,6 +38,21 @@ class Config:
|
|||||||
SESSION_LIFETIME = 3600
|
SESSION_LIFETIME = 3600
|
||||||
MAX_FILE_SIZE = 100 * 1024 * 1024 # 100MB
|
MAX_FILE_SIZE = 100 * 1024 * 1024 # 100MB
|
||||||
ALLOWED_EXTENSIONS = ['.gcode', '.stl', '.obj']
|
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
|
@classmethod
|
||||||
def get_all(cls) -> Dict[str, Any]:
|
def get_all(cls) -> Dict[str, Any]:
|
||||||
@ -215,6 +230,20 @@ def get_system_status() -> Dict[str, Any]:
|
|||||||
DATABASE_PATH = Config.DATABASE_PATH
|
DATABASE_PATH = Config.DATABASE_PATH
|
||||||
SECRET_KEY = Config.SECRET_KEY
|
SECRET_KEY = Config.SECRET_KEY
|
||||||
SESSION_LIFETIME = Config.SESSION_LIFETIME
|
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):
|
def send_email(recipient, subject, message):
|
||||||
return email_notification.send_notification(recipient, subject, message)
|
return email_notification.send_notification(recipient, subject, message)
|
||||||
|
Reference in New Issue
Block a user