[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:
parent
3e2224b782
commit
84f63c326a
1 changed files with 15 additions and 17 deletions
|
|
@ -9,6 +9,7 @@ import inspect
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
@ -929,12 +930,8 @@ class TODO:
|
||||||
|
|
||||||
force = False
|
force = False
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
ans = (
|
ans = input(t("Overwrite existing VM disk if present? (y/N): "))
|
||||||
input(t("Overwrite existing VM disk if present? (y/N): "))
|
force = self._is_yes(ans)
|
||||||
.strip()
|
|
||||||
.lower()
|
|
||||||
)
|
|
||||||
force = ans == "y"
|
|
||||||
|
|
||||||
parts = []
|
parts = []
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
|
|
@ -966,7 +963,7 @@ class TODO:
|
||||||
script_path = self._qemu_script_path()
|
script_path = self._qemu_script_path()
|
||||||
distro = self._qemu_prompt_distro()
|
distro = self._qemu_prompt_distro()
|
||||||
version = self._qemu_prompt_version(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 = [
|
parts = [
|
||||||
"sudo",
|
"sudo",
|
||||||
script_path,
|
script_path,
|
||||||
|
|
@ -976,7 +973,7 @@ class TODO:
|
||||||
"--version",
|
"--version",
|
||||||
version,
|
version,
|
||||||
]
|
]
|
||||||
if ans == "y":
|
if self._is_yes(ans):
|
||||||
parts.append("--verify")
|
parts.append("--verify")
|
||||||
cmd = " ".join(shlex.quote(p) for p in parts)
|
cmd = " ".join(shlex.quote(p) for p in parts)
|
||||||
print(f"{t('Will execute:')} {cmd}")
|
print(f"{t('Will execute:')} {cmd}")
|
||||||
|
|
@ -1026,6 +1023,11 @@ class TODO:
|
||||||
m = re.match(r"\s*(\d+)", str(size))
|
m = re.match(r"\s*(\d+)", str(size))
|
||||||
return int(m.group(1)) if m else 0
|
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
|
@staticmethod
|
||||||
def _host_free_ram_mb():
|
def _host_free_ram_mb():
|
||||||
"""RAM disponible de l'hôte en Mo (MemAvailable), 0 si inconnu."""
|
"""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.
|
# 4) Option : installer ERPLibre dans ~/git/erplibre de chaque VM.
|
||||||
install_branch = None
|
install_branch = None
|
||||||
ans = (
|
ans = input(
|
||||||
input(
|
t("Install ERPLibre into ~/git/erplibre on each VM? (y/N): ")
|
||||||
t("Install ERPLibre into ~/git/erplibre on each VM? (y/N): ")
|
|
||||||
)
|
|
||||||
.strip()
|
|
||||||
.lower()
|
|
||||||
)
|
)
|
||||||
if ans == "y":
|
if self._is_yes(ans):
|
||||||
install_branch = self._qemu_pick_branch()
|
install_branch = self._qemu_pick_branch()
|
||||||
|
|
||||||
# 5) Confirmation puis déploiement séquentiel.
|
# 5) Confirmation puis déploiement séquentiel.
|
||||||
ans = input(f"\n{t('Deploy these VMs now? (y/N): ')}").strip().lower()
|
ans = input(f"\n{t('Deploy these VMs now? (y/N): ')}")
|
||||||
if ans != "y":
|
if not self._is_yes(ans):
|
||||||
print(t("Cancelled."))
|
print(t("Cancelled."))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue