feature/generador-instaladores-linux-windows
This commit is contained in:
34
runner.py
34
runner.py
@@ -23,9 +23,34 @@ def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||
action="store_true",
|
||||
help="Inicia el motor de restauración automáticamente",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--headless",
|
||||
action="store_true",
|
||||
help="Fuerza el modo sin interfaz (Qt offscreen) para servidores sin display",
|
||||
)
|
||||
return parser.parse_args(argv)
|
||||
|
||||
|
||||
def _ensure_qt_platform(headless: bool = False) -> str:
|
||||
"""
|
||||
Selecciona el plugin de plataforma Qt en Linux. En un servidor headless (sin
|
||||
DISPLAY/WAYLAND_DISPLAY) o con --headless, usa 'offscreen' para que la app
|
||||
arranque y el motor trabaje sin X; con display usa el default ('xcb'). No toca
|
||||
nada si el usuario ya fijó QT_QPA_PLATFORM, ni en Windows/macOS.
|
||||
|
||||
Devuelve la plataforma forzada ("offscreen") o "" si se deja el default.
|
||||
"""
|
||||
if sys.platform in ("win32", "darwin"):
|
||||
return ""
|
||||
if os.environ.get("QT_QPA_PLATFORM"):
|
||||
return os.environ["QT_QPA_PLATFORM"]
|
||||
has_display = bool(os.environ.get("DISPLAY") or os.environ.get("WAYLAND_DISPLAY"))
|
||||
if headless or not has_display:
|
||||
os.environ["QT_QPA_PLATFORM"] = "offscreen"
|
||||
return "offscreen"
|
||||
return ""
|
||||
|
||||
|
||||
def _crash_log_targets() -> list[Path]:
|
||||
"""Ubicaciones candidatas para el crash log, de más a menos accesible."""
|
||||
targets: list[Path] = []
|
||||
@@ -64,6 +89,9 @@ def _show_fatal(exc: BaseException) -> None:
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
# Sin display, forzar offscreen para que crear la QApplication no falle
|
||||
# también aquí (el diálogo no se verá, pero el crash log ya quedó escrito).
|
||||
_ensure_qt_platform()
|
||||
from PySide6.QtWidgets import QApplication, QMessageBox
|
||||
|
||||
app = QApplication.instance() or QApplication(sys.argv)
|
||||
@@ -100,6 +128,7 @@ def _run() -> int:
|
||||
from app.utils.logger import app_logger
|
||||
|
||||
args = parse_args()
|
||||
qt_platform = _ensure_qt_platform(headless=args.headless)
|
||||
launch = get_launch_options()
|
||||
initialize_env()
|
||||
|
||||
@@ -109,7 +138,10 @@ def _run() -> int:
|
||||
app_logger.info("=" * 80)
|
||||
app_logger.info("CloudRestoreAS - Iniciando aplicación")
|
||||
app_logger.info(f"Directorio app: {ROOT_DIR}")
|
||||
app_logger.info("Modo: ventana siempre visible; cerrar minimiza a bandeja")
|
||||
if qt_platform == "offscreen":
|
||||
app_logger.info("Modo: sin display → plataforma Qt 'offscreen' (motor headless)")
|
||||
else:
|
||||
app_logger.info("Modo: ventana siempre visible; cerrar minimiza a bandeja")
|
||||
if start_engine:
|
||||
app_logger.info("Modo: motor auto-inicio")
|
||||
if not panel_ok:
|
||||
|
||||
Reference in New Issue
Block a user