diff --git a/linuxinstaller/PythonActions.py b/linuxinstaller/PythonActions.py index 65e5838..bf0173b 100644 --- a/linuxinstaller/PythonActions.py +++ b/linuxinstaller/PythonActions.py @@ -1,5 +1,8 @@ import socket import subprocess +import GitActions +from rich.console import Console +from rich.table import Table def getHostName(): return socket.gethostname() @@ -11,3 +14,28 @@ def getDomain(): def setFQDN(fqdn): result = subprocess.run(['hostnamectl', 'hostname', fqdn], check=True) return result.returncode == 0 + + +### Cartouche de status + +def print_status(): + # Récupération des infos + hostname = getHostName() + domain = getDomain() + currentBranch = GitActions.getBranch() + + # Affichage du statut + console = Console() + console.print() + console.print("=== Menu de configuration Libretic ===", style="bold red") + console.print() + table = Table(show_header=True, header_style="bold dim") + table.add_column("Paramètre", style="bold magenta") + table.add_column("Valeur") + table.add_column("Statut", justify="center") + table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == "main" else "[yellow]Attention") + table.add_row("Hostname", hostname, "[green]OK" if hostname != "unassigned-hostname" else "[red]KO") + console.print(table) + console.print() + + diff --git a/linuxinstaller/linuxinstaller.py b/linuxinstaller/linuxinstaller.py index cff83c4..068f5e2 100644 --- a/linuxinstaller/linuxinstaller.py +++ b/linuxinstaller/linuxinstaller.py @@ -1,7 +1,6 @@ from InquirerPy import inquirer from InquirerPy import prompt from rich.console import Console -from rich.table import Table import AnsibleActions import PythonActions import GitActions @@ -11,29 +10,6 @@ import syslog import os -### Cartouche de status - -def print_status(): - # Récupération des infos - hostname = PythonActions.getHostName() - domain = PythonActions.getDomain() - currentBranch = GitActions.getBranch() - - # Affichage du statut - console = Console() - console.print() - console.print("=== Menu de configuration Libretic ===", style="bold red") - console.print() - table = Table(show_header=True, header_style="bold dim") - table.add_column("Paramètre", style="bold magenta") - table.add_column("Valeur") - table.add_column("Statut", justify="center") - table.add_row("Environnement du poste", currentBranch, "[green]OK" if currentBranch == "main" else "[yellow]Attention") - table.add_row("Hostname", hostname, "[green]OK" if hostname != "unassigned-hostname" else "[red]KO") - console.print(table) - console.print() - - # Chargement du fichier de configuration def readConfig(configFile): try: @@ -172,7 +148,7 @@ def main(): while not cmdlineOptionPassed: - print_status() + PythonActions.print_status() console = Console() console.print("Choisir une des options suivantes", style="bold blue") action = inquirer.select(