Déplacement de la fonction status
This commit is contained in:
parent
0768049125
commit
47a21aa6d9
2 changed files with 29 additions and 25 deletions
|
@ -1,5 +1,8 @@
|
||||||
import socket
|
import socket
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import GitActions
|
||||||
|
from rich.console import Console
|
||||||
|
from rich.table import Table
|
||||||
|
|
||||||
def getHostName():
|
def getHostName():
|
||||||
return socket.gethostname()
|
return socket.gethostname()
|
||||||
|
@ -11,3 +14,28 @@ def getDomain():
|
||||||
def setFQDN(fqdn):
|
def setFQDN(fqdn):
|
||||||
result = subprocess.run(['hostnamectl', 'hostname', fqdn], check=True)
|
result = subprocess.run(['hostnamectl', 'hostname', fqdn], check=True)
|
||||||
return result.returncode == 0
|
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()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
from InquirerPy import inquirer
|
from InquirerPy import inquirer
|
||||||
from InquirerPy import prompt
|
from InquirerPy import prompt
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.table import Table
|
|
||||||
import AnsibleActions
|
import AnsibleActions
|
||||||
import PythonActions
|
import PythonActions
|
||||||
import GitActions
|
import GitActions
|
||||||
|
@ -11,29 +10,6 @@ import syslog
|
||||||
import os
|
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
|
# Chargement du fichier de configuration
|
||||||
def readConfig(configFile):
|
def readConfig(configFile):
|
||||||
try:
|
try:
|
||||||
|
@ -172,7 +148,7 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
while not cmdlineOptionPassed:
|
while not cmdlineOptionPassed:
|
||||||
print_status()
|
PythonActions.print_status()
|
||||||
console = Console()
|
console = Console()
|
||||||
console.print("Choisir une des options suivantes", style="bold blue")
|
console.print("Choisir une des options suivantes", style="bold blue")
|
||||||
action = inquirer.select(
|
action = inquirer.select(
|
||||||
|
|
Loading…
Reference in a new issue