refactor: one refusal path to stderr and events

Library functions printed their refusal and exited, each deciding on its
own whether --events got an error event. --cores-dir, --installed-cores
with no core, a list without system_cores or standalone_builds, a pack
that cannot be used, a board list a run needs and --dest alone beside
two setups ended on code 1 with no reason in the stream.

They now raise Refusal (installer/refusal.py), carrying the stage, the
reason, the platform, the lines and the code. The install, an action
framed by events and main report it once: the error event, then the
same lines on stderr, so the text and exit codes stay as they were.
This commit is contained in:
Abdessamad Derraz committed 2026-11-21 19:50:46 +01:00
1 parent ced68a9135
commit eba627aa89
20 files changed
+542 -402

No files matched your search

+12 -1
View File
@@ -57,6 +57,7 @@ from installer.pack_source import NOT_IN_PACK, pack_holds_trees, pack_lacks, pac
from installer.paths import _entry_path, shown_path
from installer.plan import CONFIRM_FROM_BYTES, _check_free_space, _print_plan, bulk_hint
from installer.platforms import display_name
from installer.refusal import Refusal
from installer.romm import ROMM_SCAN_WORDS, _check_run_romm, _pass_romm_layout
from installer.run_files import _select_setup_files
from installer.run_setups import (
@@ -762,7 +763,17 @@ def _finish_install(run: _InstallRun, real_stdout: TextIO) -> None:
def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
"""One run of the installer, once the options are read."""
"""One run of the installer, once the options are read, a refusal
reported where it ends the run: its error event before end, its lines
before what the unwinding run says."""
try:
_install_run(args, real_stdout)
except Refusal as refusal:
refusal.report()
raise
def _install_run(args: argparse.Namespace, real_stdout: TextIO) -> None:
run = _start_install(args, real_stdout)
# Early exit for listing