42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
from __future__ import annotations
|
|
from textual.screen import Screen
|
|
from textual.widgets import Button, Static
|
|
from textual.containers import Vertical
|
|
from textual.app import ComposeResult
|
|
from ...services.deps_ext import check_dependencies_ext, install_dependencies_ext
|
|
from ...services.config import get_config, ensure_runtime_dirs
|
|
from .playbook_browser import PlaybookBrowserScreen
|
|
|
|
|
|
class StartupCheckScreen(Screen):
|
|
def compose(self) -> ComposeResult:
|
|
self.status = Static("", id="status")
|
|
yield Vertical(
|
|
Static("Autocheck der Abhängigkeiten", id="title"),
|
|
self.status,
|
|
Button("Installieren und fortfahren", id="install", variant="primary"),
|
|
Button("Ohne Installation fortfahren", id="continue"),
|
|
)
|
|
|
|
def on_mount(self) -> None:
|
|
ensure_runtime_dirs()
|
|
_ = get_config() # Konfig initialisieren
|
|
info = check_dependencies_ext()
|
|
lines = []
|
|
if info["messages"]:
|
|
lines.extend([f"- {m}" for m in info["messages"]])
|
|
if info["missing_bins"]:
|
|
lines.append("Fehlende Pakete: " + ", ".join(info["missing_bins"]))
|
|
if info["missing_pip"]:
|
|
lines.append("Fehlende Python-Module: " + ", ".join(info["missing_pip"]))
|
|
if not lines:
|
|
lines = ["Alle benötigten Komponenten scheinen vorhanden zu sein."]
|
|
self.status.update("\\n".join(lines))
|
|
|
|
def on_button_pressed(self, event: Button.Pressed) -> None:
|
|
info = check_dependencies_ext()
|
|
if event.button.id == "install":
|
|
install_dependencies_ext(info["missing_bins"], info["missing_pip"])
|
|
# Weiter zum Browser
|
|
self.app.push_screen(PlaybookBrowserScreen())
|