From c140b418d53e0b76abdd656e4dd543ca2b63cde3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Thu, 30 Jul 2026 03:23:28 +0000 Subject: [PATCH] =?UTF-8?q?[IMP]=20script=20todo:=20=C2=AB=20Tester=20une?= =?UTF-8?q?=20VM=20=C2=BB=20=E2=80=94=20option=20d'installer=20un=20autre?= =?UTF-8?q?=20navigateur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- script/todo/todo.py | 70 ++++++++++++++++++++++------------------ script/todo/todo_i18n.py | 8 +++++ 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/script/todo/todo.py b/script/todo/todo.py index cecaf06..6d03ee4 100755 --- a/script/todo/todo.py +++ b/script/todo/todo.py @@ -1384,43 +1384,20 @@ class TODO: print(f"⚠ {msg}") def _qemu_choose_cli_browser(self): - """Offre la LISTE des navigateurs CLI installés (ou propose d'en - installer un) et renvoie celui choisi, sinon None.""" - from script.todo.qemu_install_monitor import ( - CLI_BROWSERS, - INSTALLABLE_BROWSERS, - browser_install_command, - ) + """Offre la LISTE des navigateurs CLI installés, plus une option pour + en INSTALLER un autre, et renvoie celui choisi, sinon None.""" + from script.todo.qemu_install_monitor import CLI_BROWSERS available = [b for b in CLI_BROWSERS if shutil.which(b)] if not available: - print(t("No CLI browser installed. Which 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 - if len(available) == 1: - return available[0] + return self._qemu_install_cli_browser() print(f"\n{t('Which browser to view the page?')}") for i, b in enumerate(available, 1): 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: return available[0] try: @@ -1431,6 +1408,37 @@ class TODO: pass 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 # ------------------------------------------------------------------ # diff --git a/script/todo/todo_i18n.py b/script/todo/todo_i18n.py index 053c7a9..a5703c6 100644 --- a/script/todo/todo_i18n.py +++ b/script/todo/todo_i18n.py @@ -1448,6 +1448,14 @@ TRANSLATIONS = { "fr": "Aucun navigateur CLI installé. Lequel installer ?", "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): ": { "fr": "Choix (numéro, vide = w3m) : ", "en": "Choice (number, blank = w3m): ",