[FIX] script todo: accept "o"/"oui" at QEMU yes/no prompts

The confirmations only matched "y", but the French prompts show "(o/N)",
so answering "o" (oui) was treated as no — the infra deployment aborted
with "Annulé." right after the user confirmed. Add a _is_yes() helper
(y/yes/o/oui) and use it for the infra deploy confirmation, the ERPLibre
install prompt, the disk-overwrite prompt and the SHA256 verify prompt.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mathieu Benoit 2026-07-19 07:07:20 +00:00
parent 3e2224b782
commit 84f63c326a

View file

@ -9,6 +9,7 @@ import inspect
import json
import logging
import os
import re
import shlex
import shutil
import subprocess
@ -929,12 +930,8 @@ class TODO:
force = False
if not dry_run:
ans = (
input(t("Overwrite existing VM disk if present? (y/N): "))
.strip()
.lower()
)
force = ans == "y"
ans = input(t("Overwrite existing VM disk if present? (y/N): "))
force = self._is_yes(ans)
parts = []
if not dry_run:
@ -966,7 +963,7 @@ class TODO:
script_path = self._qemu_script_path()
distro = self._qemu_prompt_distro()
version = self._qemu_prompt_version(distro)
ans = input(t("Verify SHA256 after download? (y/N): ")).strip().lower()
ans = input(t("Verify SHA256 after download? (y/N): "))
parts = [
"sudo",
script_path,
@ -976,7 +973,7 @@ class TODO:
"--version",
version,
]
if ans == "y":
if self._is_yes(ans):
parts.append("--verify")
cmd = " ".join(shlex.quote(p) for p in parts)
print(f"{t('Will execute:')} {cmd}")
@ -1026,6 +1023,11 @@ class TODO:
m = re.match(r"\s*(\d+)", str(size))
return int(m.group(1)) if m else 0
@staticmethod
def _is_yes(ans):
"""Réponse affirmative, FR et EN (o/oui/y/yes)."""
return ans.strip().lower() in ("y", "yes", "o", "oui")
@staticmethod
def _host_free_ram_mb():
"""RAM disponible de l'hôte en Mo (MemAvailable), 0 si inconnu."""
@ -1240,19 +1242,15 @@ class TODO:
# 4) Option : installer ERPLibre dans ~/git/erplibre de chaque VM.
install_branch = None
ans = (
input(
t("Install ERPLibre into ~/git/erplibre on each VM? (y/N): ")
)
.strip()
.lower()
ans = input(
t("Install ERPLibre into ~/git/erplibre on each VM? (y/N): ")
)
if ans == "y":
if self._is_yes(ans):
install_branch = self._qemu_pick_branch()
# 5) Confirmation puis déploiement séquentiel.
ans = input(f"\n{t('Deploy these VMs now? (y/N): ')}").strip().lower()
if ans != "y":
ans = input(f"\n{t('Deploy these VMs now? (y/N): ')}")
if not self._is_yes(ans):
print(t("Cancelled."))
return