feature/integracion-panel-restore-targets
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
"""Motor principal de la aplicación."""
|
||||
|
||||
import platform
|
||||
import socket
|
||||
from typing import Optional
|
||||
from pathlib import Path
|
||||
from PySide6.QtCore import QObject, Signal, QThreadPool
|
||||
|
||||
from .file_watcher import FileWatcher, FileStabilityChecker, calculate_file_hash
|
||||
from .restore_worker import RestoreWorker
|
||||
from .. import __version__
|
||||
from ..db.job_repository import JobRepository
|
||||
from ..db.event_repository import EventRepository
|
||||
from ..db.config_repository import ConfigRepository
|
||||
from ..constants import JobStatus, DEFAULT_CONFIG
|
||||
from ..panel import panel_client
|
||||
from ..utils.logger import app_logger
|
||||
|
||||
|
||||
@@ -41,7 +45,8 @@ class RestoreEngine(QObject):
|
||||
|
||||
# Configuración
|
||||
self._config = self._load_config()
|
||||
|
||||
self._report_instance_config_to_panel()
|
||||
|
||||
app_logger.info("RestoreEngine inicializado")
|
||||
|
||||
def _load_config(self) -> dict:
|
||||
@@ -66,7 +71,8 @@ class RestoreEngine(QObject):
|
||||
ConfigRepository.set("app_config", config)
|
||||
self._config = config
|
||||
app_logger.info("Configuración guardada")
|
||||
|
||||
self._report_instance_config_to_panel()
|
||||
|
||||
# Reconfigurar file watcher si está corriendo
|
||||
if self._running:
|
||||
self._restart_file_watcher()
|
||||
@@ -103,7 +109,8 @@ class RestoreEngine(QObject):
|
||||
|
||||
self._running = True
|
||||
self._paused = False
|
||||
|
||||
self._report_instance_config_to_panel()
|
||||
|
||||
EventRepository.create("INFO", "Motor iniciado")
|
||||
app_logger.info("Motor iniciado")
|
||||
|
||||
@@ -190,6 +197,30 @@ class RestoreEngine(QObject):
|
||||
|
||||
return stats
|
||||
|
||||
def _report_instance_config_to_panel(self) -> None:
|
||||
"""Reporta input_folder al PANEL (best-effort, no bloquea el flujo)."""
|
||||
panel_cfg = self._config.get("panel", {})
|
||||
api_url = (panel_cfg.get("api_url") or "").strip()
|
||||
api_token = (panel_cfg.get("api_token") or "").strip()
|
||||
if not api_url or not api_token:
|
||||
return
|
||||
|
||||
input_folder = (self._config.get("paths") or {}).get("input_folder") or ""
|
||||
try:
|
||||
host_name = socket.gethostname() or platform.node()
|
||||
except Exception:
|
||||
host_name = platform.node()
|
||||
|
||||
instance_key = (panel_cfg.get("instance_key") or "").strip() or None
|
||||
panel_client.report_instance_config(
|
||||
api_url=api_url,
|
||||
api_token=api_token,
|
||||
input_folder=input_folder,
|
||||
host_name=host_name,
|
||||
app_version=__version__,
|
||||
instance_key=instance_key,
|
||||
)
|
||||
|
||||
def _validate_config(self) -> bool:
|
||||
"""Valida que la configuración sea correcta."""
|
||||
paths = self._config["paths"]
|
||||
|
||||
Reference in New Issue
Block a user