[IMP] script todo: « Tester une VM » — option d'installer un autre navigateur

Le choix du navigateur propose désormais « [i] Installer un autre
navigateur » en plus des navigateurs déjà installés. L'option ouvre le
sous-menu d'installation (choix w3m/lynx/links/elinks, commande adaptée à
l'OS, validation), même s'il existe déjà un navigateur.

Le flux d'installation est extrait dans _qemu_install_cli_browser
(réutilisé quand aucun navigateur n'est présent ET via l'option [i]).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mathieu Benoit 2026-07-30 03:23:28 +00:00
parent 14fa807221
commit c140b418d5
2 changed files with 47 additions and 31 deletions

View file

@ -1384,43 +1384,20 @@ class TODO:
print(f"{msg}") print(f"{msg}")
def _qemu_choose_cli_browser(self): def _qemu_choose_cli_browser(self):
"""Offre la LISTE des navigateurs CLI installés (ou propose d'en """Offre la LISTE des navigateurs CLI installés, plus une option pour
installer un) et renvoie celui choisi, sinon None.""" en INSTALLER un autre, et renvoie celui choisi, sinon None."""
from script.todo.qemu_install_monitor import ( from script.todo.qemu_install_monitor import CLI_BROWSERS
CLI_BROWSERS,
INSTALLABLE_BROWSERS,
browser_install_command,
)
available = [b for b in CLI_BROWSERS if shutil.which(b)] available = [b for b in CLI_BROWSERS if shutil.which(b)]
if not available: if not available:
print(t("No CLI browser installed. Which to install?")) return self._qemu_install_cli_browser()
for i, (b, desc) in enumerate(INSTALLABLE_BROWSERS, 1):
print(f" [{i}] {desc}{' *' if i == 1 else ''}")
sel = input(t("Choice (number, blank = w3m): ")).strip()
browser = INSTALLABLE_BROWSERS[0][0]
try:
idx = int(sel) - 1
if 0 <= idx < len(INSTALLABLE_BROWSERS):
browser = INSTALLABLE_BROWSERS[idx][0]
except ValueError:
pass
cmd = browser_install_command(browser)
if not cmd:
print(t("Unknown package manager; install it manually."))
return None
printable = " ".join(cmd)
print(f"{t('Command:')} {printable}")
if not self._is_yes(input(t("Install now? (y/N): "))):
return None
os.system(printable)
return browser if shutil.which(browser) else None
if len(available) == 1:
return available[0]
print(f"\n{t('Which browser to view the page?')}") print(f"\n{t('Which browser to view the page?')}")
for i, b in enumerate(available, 1): for i, b in enumerate(available, 1):
print(f" [{i}] {b}{' *' if i == 1 else ''}") print(f" [{i}] {b}{' *' if i == 1 else ''}")
sel = input(t("Choice (number, blank = first): ")).strip() print(f" [i] {t('Install another browser')}")
sel = input(t("Choice (number, blank = first): ")).strip().lower()
if sel == "i":
return self._qemu_install_cli_browser()
if not sel: if not sel:
return available[0] return available[0]
try: try:
@ -1431,6 +1408,37 @@ class TODO:
pass pass
return available[0] return available[0]
def _qemu_install_cli_browser(self):
"""Demande QUEL navigateur CLI installer, affiche la commande adaptée
à l'OS, l'exécute après validation. Renvoie le binaire installé ou
None."""
from script.todo.qemu_install_monitor import (
INSTALLABLE_BROWSERS,
browser_install_command,
)
print(f"\n{t('Which browser to install?')}")
for i, (b, desc) in enumerate(INSTALLABLE_BROWSERS, 1):
print(f" [{i}] {desc}{' *' if i == 1 else ''}")
sel = input(t("Choice (number, blank = w3m): ")).strip()
browser = INSTALLABLE_BROWSERS[0][0]
try:
idx = int(sel) - 1
if 0 <= idx < len(INSTALLABLE_BROWSERS):
browser = INSTALLABLE_BROWSERS[idx][0]
except ValueError:
pass
cmd = browser_install_command(browser)
if not cmd:
print(t("Unknown package manager; install it manually."))
return None
printable = " ".join(cmd)
print(f"{t('Command:')} {printable}")
if not self._is_yes(input(t("Install now? (y/N): "))):
return None
os.system(printable)
return browser if shutil.which(browser) else None
# ------------------------------------------------------------------ # # ------------------------------------------------------------------ #
# Redimensionnement du disque d'une VM # Redimensionnement du disque d'une VM
# ------------------------------------------------------------------ # # ------------------------------------------------------------------ #

View file

@ -1448,6 +1448,14 @@ TRANSLATIONS = {
"fr": "Aucun navigateur CLI installé. Lequel installer ?", "fr": "Aucun navigateur CLI installé. Lequel installer ?",
"en": "No CLI browser installed. Which to install?", "en": "No CLI browser installed. Which to install?",
}, },
"Which browser to install?": {
"fr": "Quel navigateur installer ?",
"en": "Which browser to install?",
},
"Install another browser": {
"fr": "Installer un autre navigateur",
"en": "Install another browser",
},
"Choice (number, blank = w3m): ": { "Choice (number, blank = w3m): ": {
"fr": "Choix (numéro, vide = w3m) : ", "fr": "Choix (numéro, vide = w3m) : ",
"en": "Choice (number, blank = w3m): ", "en": "Choice (number, blank = w3m): ",