mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
fix: a refusal mid-run ends on the summary
This commit is contained in:
1 parent
38f81892ee
commit
f7157a5191
9 files changed
+179
-111
No files matched your search
+1
-1
@@ -16,7 +16,7 @@
|
||||
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
|
||||
# the site's build rewrites this line there (scripts/sitebootstrap.py).
|
||||
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
$defaultInstallSha256 = "bdc0c4923243af6fb93f9a9353aec6e89240610be1a2fb315a6bcd04e3c63c13"
|
||||
$defaultInstallSha256 = "8a5606206be6b53db269d6003d13a22487c4dde99c7121aaef608e65eb2546c3"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
$maximumInstallerBytes = 8MB
|
||||
|
||||
+70
-50
@@ -52,6 +52,7 @@ import weakref
|
||||
import xml.etree.ElementTree as ET
|
||||
import zipfile
|
||||
from collections.abc import Callable, Collection, Iterable, Iterator, Mapping
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path, PurePosixPath, PureWindowsPath
|
||||
from typing import IO, Any, BinaryIO, ContextManager, NamedTuple, NoReturn, TextIO
|
||||
|
||||
@@ -23114,7 +23115,8 @@ def _install_standalone_folders(run: _InstallRun) -> bool:
|
||||
print(f" {EVERYTHING_IN_PLACE}")
|
||||
continue
|
||||
size = sum(entry.get("size", 0) for entry in to_download)
|
||||
_check_free_space(folder, size, code=1 if run.total_downloaded else 2)
|
||||
with run.writes(len(to_download)):
|
||||
_check_free_space(folder, size, code=1 if run.total_downloaded else 2)
|
||||
progress = Progress(len(to_download), size, term)
|
||||
failed, interrupted = download_files(
|
||||
to_download, folder, jobs=args.jobs, verbose=args.verbose,
|
||||
@@ -23320,6 +23322,20 @@ class _InstallRun:
|
||||
# No setup found, the standalone emulator folders filled instead:
|
||||
# the run still ends on its summary, exit code and result.
|
||||
self.standalone_only = False
|
||||
# A step about to write was reached: a refusal from then on still
|
||||
# ends on the summary of what the run installed before it.
|
||||
self.writing = False
|
||||
|
||||
@contextmanager
|
||||
def writes(self, pending: int) -> Iterator[None]:
|
||||
"""The checks before a step writes, pending the files it would
|
||||
write, counted as still to install when a refusal stops it."""
|
||||
self.writing = True
|
||||
try:
|
||||
yield
|
||||
except Refusal:
|
||||
self.files_pending += pending
|
||||
raise
|
||||
|
||||
|
||||
def _start_install(args: argparse.Namespace, real_stdout: TextIO) -> _InstallRun:
|
||||
@@ -24004,39 +24020,29 @@ def _pass_download_head(run: _InstallRun, p: _PlatformPass, fetched: list[dict],
|
||||
|
||||
def _pass_make_folder(run: _InstallRun, p: _PlatformPass, written: int) -> bool:
|
||||
"""The space checked and the BIOS folder made. True when it was created."""
|
||||
args, plat_name, bios_path = run.args, p.plat_name, p.bios_path
|
||||
# Checked before the folder is created: a run stopped for space
|
||||
# left an empty BIOS folder behind. The data trees count too,
|
||||
# written after the files on the same drive.
|
||||
_check_free_space(bios_path, written, plat_name,
|
||||
1 if run.total_downloaded else 2, on_its_card(plat_name, bios_path))
|
||||
p.space_checked = True
|
||||
created = not bios_path.exists()
|
||||
try:
|
||||
bios_path.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as exc:
|
||||
sys.stdout.flush()
|
||||
# Said to a script too: the run ended on code 2 with no error
|
||||
# and no summary, what was installed before it unsaid.
|
||||
EVENTS.emit("error", stage="dest", reason="not_writable", platform=plat_name,
|
||||
message=f"{bios_path} cannot be created: {exc.strerror}")
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_up_to_date, pending=run.files_pending + len(p.to_download),
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=False,
|
||||
)
|
||||
print(f"\nCannot create {bios_path}.", file=sys.stderr)
|
||||
print(f" {exc.strerror}.", file=sys.stderr)
|
||||
print(_write_advice(bios_path, bios_path in run.assumed_dests, plat_name),
|
||||
file=sys.stderr)
|
||||
# The documented code for a folder that cannot be written,
|
||||
# as when it exists read-only. 1 once an earlier platform
|
||||
# of the run installed something.
|
||||
sys.exit(1 if run.total_downloaded else 2)
|
||||
plat_name, bios_path = p.plat_name, p.bios_path
|
||||
with run.writes(len(p.to_download)):
|
||||
# Checked before the folder is created: a run stopped for space
|
||||
# left an empty BIOS folder behind. The data trees count too,
|
||||
# written after the files on the same drive.
|
||||
_check_free_space(bios_path, written, plat_name,
|
||||
1 if run.total_downloaded else 2, on_its_card(plat_name, bios_path))
|
||||
p.space_checked = True
|
||||
created = not bios_path.exists()
|
||||
try:
|
||||
bios_path.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as exc:
|
||||
sys.stdout.flush()
|
||||
# The documented code for a folder that cannot be written,
|
||||
# as when it exists read-only. 1 once an earlier platform
|
||||
# of the run installed something.
|
||||
raise Refusal(
|
||||
"dest", "not_writable", plat_name,
|
||||
f"\nCannot create {bios_path}.", f" {exc.strerror}.",
|
||||
_write_advice(bios_path, bios_path in run.assumed_dests, plat_name),
|
||||
code=1 if run.total_downloaded else 2,
|
||||
message=f"{bios_path} cannot be created: {exc.strerror}",
|
||||
) from None
|
||||
if created:
|
||||
detail(f" Created {shown_path(bios_path)}")
|
||||
return created
|
||||
@@ -24210,9 +24216,10 @@ def _pass_data_trees(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
if writable and not p.space_checked:
|
||||
# With every BIOS file in place, the trees alone: checked
|
||||
# before the first archive is written.
|
||||
_check_free_space(p.bios_path, bytes_written([], writable), p.plat_name,
|
||||
1 if run.total_downloaded else 2,
|
||||
on_its_card(p.plat_name, p.bios_path))
|
||||
with run.writes(sum(len(state[1]) for _entry, state in writable)):
|
||||
_check_free_space(p.bios_path, bytes_written([], writable), p.plat_name,
|
||||
1 if run.total_downloaded else 2,
|
||||
on_its_card(p.plat_name, p.bios_path))
|
||||
if writable:
|
||||
detail("\nData directories:")
|
||||
for entry, state in writable:
|
||||
@@ -24332,6 +24339,22 @@ def _install_setup(run: _InstallRun, plat_name: str, bios_path: Path) -> bool:
|
||||
return p is not None and _apply_setup_files(run, p)
|
||||
|
||||
|
||||
def _emit_summary(run: _InstallRun) -> None:
|
||||
"""The failures and summary events of what the run did, at its end or
|
||||
where a refusal stopped it."""
|
||||
args = run.args
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_verified if args.check or args.dry_run else run.total_up_to_date,
|
||||
pending=run.check_pending if args.check else run.files_pending,
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=run.total_interrupted,
|
||||
)
|
||||
|
||||
|
||||
def _finish_install(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
"""The run's summary event, its exit code and its result."""
|
||||
args, platforms = run.args, run.platforms
|
||||
@@ -24340,16 +24363,7 @@ def _finish_install(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
# The matches are the answer: nothing was installed.
|
||||
sys.exit(4 if getattr(args, "find_failed", False) else 0)
|
||||
if not run.listing:
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_verified if args.check or args.dry_run else run.total_up_to_date,
|
||||
pending=run.check_pending if args.check else run.files_pending,
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=run.total_interrupted,
|
||||
)
|
||||
_emit_summary(run)
|
||||
# A check scripted as `--check && launch` reads the exit code only. Its
|
||||
# own code, 3: with 1, a check that found files missing could not be
|
||||
# told from a check that never ran (a list refused, a --from missing).
|
||||
@@ -24391,15 +24405,21 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
"""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."""
|
||||
run = None
|
||||
try:
|
||||
_install_run(args, real_stdout)
|
||||
run = _start_install(args, real_stdout)
|
||||
_install_run(run, real_stdout)
|
||||
except Refusal as refusal:
|
||||
refusal.report()
|
||||
# A stop once a step began writing reports what the run installed
|
||||
# before it, whatever stopped it.
|
||||
if run is not None and run.writing and not run.listing:
|
||||
_emit_summary(run)
|
||||
raise
|
||||
|
||||
|
||||
def _install_run(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
run = _start_install(args, real_stdout)
|
||||
def _install_run(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
args = run.args
|
||||
|
||||
# Early exit for listing
|
||||
if args.list_platforms:
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
|
||||
# curl or wget stop on a cut transfer before the hash is read: the site's
|
||||
# build rewrites this line there (scripts/sitebootstrap.py).
|
||||
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
|
||||
DEFAULT_INSTALL_SHA256="bdc0c4923243af6fb93f9a9353aec6e89240610be1a2fb315a6bcd04e3c63c13"
|
||||
DEFAULT_INSTALL_SHA256="8a5606206be6b53db269d6003d13a22487c4dde99c7121aaef608e65eb2546c3"
|
||||
# The pin above refuses any changed byte: this cap only stops a body that
|
||||
# cannot be the installer (a sign-in portal's page) before it is hashed.
|
||||
MAX_INSTALLER_BYTES=8388608
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
{
|
||||
"dest": "roms/ports/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1488117,
|
||||
"sha256": "bdc0c4923243af6fb93f9a9353aec6e89240610be1a2fb315a6bcd04e3c63c13",
|
||||
"size": 1488572,
|
||||
"sha256": "8a5606206be6b53db269d6003d13a22487c4dde99c7121aaef608e65eb2546c3",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1541742,
|
||||
"sha256": "5a3b297cbf86685aecfe52781dc4cd6bc2c8fea64c2c1f7ecd4f102d56fd5097"
|
||||
"size": 1542197,
|
||||
"sha256": "3634e306defdfaecd44315a693884c3f754829cf3f8df6bd4bd1866cbcdad8da"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1488117,
|
||||
"sha256": "bdc0c4923243af6fb93f9a9353aec6e89240610be1a2fb315a6bcd04e3c63c13",
|
||||
"size": 1488572,
|
||||
"sha256": "8a5606206be6b53db269d6003d13a22487c4dde99c7121aaef608e65eb2546c3",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1488117,
|
||||
"sha256": "bdc0c4923243af6fb93f9a9353aec6e89240610be1a2fb315a6bcd04e3c63c13",
|
||||
"size": 1488572,
|
||||
"sha256": "8a5606206be6b53db269d6003d13a22487c4dde99c7121aaef608e65eb2546c3",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
+53
-49
@@ -407,39 +407,29 @@ def _pass_download_head(run: _InstallRun, p: _PlatformPass, fetched: list[dict],
|
||||
|
||||
def _pass_make_folder(run: _InstallRun, p: _PlatformPass, written: int) -> bool:
|
||||
"""The space checked and the BIOS folder made. True when it was created."""
|
||||
args, plat_name, bios_path = run.args, p.plat_name, p.bios_path
|
||||
# Checked before the folder is created: a run stopped for space
|
||||
# left an empty BIOS folder behind. The data trees count too,
|
||||
# written after the files on the same drive.
|
||||
_check_free_space(bios_path, written, plat_name,
|
||||
1 if run.total_downloaded else 2, on_its_card(plat_name, bios_path))
|
||||
p.space_checked = True
|
||||
created = not bios_path.exists()
|
||||
try:
|
||||
bios_path.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as exc:
|
||||
sys.stdout.flush()
|
||||
# Said to a script too: the run ended on code 2 with no error
|
||||
# and no summary, what was installed before it unsaid.
|
||||
EVENTS.emit("error", stage="dest", reason="not_writable", platform=plat_name,
|
||||
message=f"{bios_path} cannot be created: {exc.strerror}")
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_up_to_date, pending=run.files_pending + len(p.to_download),
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=False,
|
||||
)
|
||||
print(f"\nCannot create {bios_path}.", file=sys.stderr)
|
||||
print(f" {exc.strerror}.", file=sys.stderr)
|
||||
print(_write_advice(bios_path, bios_path in run.assumed_dests, plat_name),
|
||||
file=sys.stderr)
|
||||
# The documented code for a folder that cannot be written,
|
||||
# as when it exists read-only. 1 once an earlier platform
|
||||
# of the run installed something.
|
||||
sys.exit(1 if run.total_downloaded else 2)
|
||||
plat_name, bios_path = p.plat_name, p.bios_path
|
||||
with run.writes(len(p.to_download)):
|
||||
# Checked before the folder is created: a run stopped for space
|
||||
# left an empty BIOS folder behind. The data trees count too,
|
||||
# written after the files on the same drive.
|
||||
_check_free_space(bios_path, written, plat_name,
|
||||
1 if run.total_downloaded else 2, on_its_card(plat_name, bios_path))
|
||||
p.space_checked = True
|
||||
created = not bios_path.exists()
|
||||
try:
|
||||
bios_path.mkdir(parents=True, exist_ok=True)
|
||||
except OSError as exc:
|
||||
sys.stdout.flush()
|
||||
# The documented code for a folder that cannot be written,
|
||||
# as when it exists read-only. 1 once an earlier platform
|
||||
# of the run installed something.
|
||||
raise Refusal(
|
||||
"dest", "not_writable", plat_name,
|
||||
f"\nCannot create {bios_path}.", f" {exc.strerror}.",
|
||||
_write_advice(bios_path, bios_path in run.assumed_dests, plat_name),
|
||||
code=1 if run.total_downloaded else 2,
|
||||
message=f"{bios_path} cannot be created: {exc.strerror}",
|
||||
) from None
|
||||
if created:
|
||||
detail(f" Created {shown_path(bios_path)}")
|
||||
return created
|
||||
@@ -613,9 +603,10 @@ def _pass_data_trees(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
if writable and not p.space_checked:
|
||||
# With every BIOS file in place, the trees alone: checked
|
||||
# before the first archive is written.
|
||||
_check_free_space(p.bios_path, bytes_written([], writable), p.plat_name,
|
||||
1 if run.total_downloaded else 2,
|
||||
on_its_card(p.plat_name, p.bios_path))
|
||||
with run.writes(sum(len(state[1]) for _entry, state in writable)):
|
||||
_check_free_space(p.bios_path, bytes_written([], writable), p.plat_name,
|
||||
1 if run.total_downloaded else 2,
|
||||
on_its_card(p.plat_name, p.bios_path))
|
||||
if writable:
|
||||
detail("\nData directories:")
|
||||
for entry, state in writable:
|
||||
@@ -735,6 +726,22 @@ def _install_setup(run: _InstallRun, plat_name: str, bios_path: Path) -> bool:
|
||||
return p is not None and _apply_setup_files(run, p)
|
||||
|
||||
|
||||
def _emit_summary(run: _InstallRun) -> None:
|
||||
"""The failures and summary events of what the run did, at its end or
|
||||
where a refusal stopped it."""
|
||||
args = run.args
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_verified if args.check or args.dry_run else run.total_up_to_date,
|
||||
pending=run.check_pending if args.check else run.files_pending,
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=run.total_interrupted,
|
||||
)
|
||||
|
||||
|
||||
def _finish_install(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
"""The run's summary event, its exit code and its result."""
|
||||
args, platforms = run.args, run.platforms
|
||||
@@ -743,16 +750,7 @@ def _finish_install(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
# The matches are the answer: nothing was installed.
|
||||
sys.exit(4 if getattr(args, "find_failed", False) else 0)
|
||||
if not run.listing:
|
||||
if run.failures:
|
||||
EVENTS.emit("failures", failed=failure_events(run.failures))
|
||||
EVENTS.emit(
|
||||
"summary", mode=_event_mode(args), installed=run.total_downloaded,
|
||||
up_to_date=run.total_verified if args.check or args.dry_run else run.total_up_to_date,
|
||||
pending=run.check_pending if args.check else run.files_pending,
|
||||
failed=[{"dest": dest, "reason": str(reason)} for dest, reason in run.failures],
|
||||
skipped=_skipped(run.omitted_seen), left_out=_left_out_events(run.left_out_seen),
|
||||
kept=KEPT.summary(), interrupted=run.total_interrupted,
|
||||
)
|
||||
_emit_summary(run)
|
||||
# A check scripted as `--check && launch` reads the exit code only. Its
|
||||
# own code, 3: with 1, a check that found files missing could not be
|
||||
# told from a check that never ran (a list refused, a --from missing).
|
||||
@@ -794,15 +792,21 @@ def _install(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
"""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."""
|
||||
run = None
|
||||
try:
|
||||
_install_run(args, real_stdout)
|
||||
run = _start_install(args, real_stdout)
|
||||
_install_run(run, real_stdout)
|
||||
except Refusal as refusal:
|
||||
refusal.report()
|
||||
# A stop once a step began writing reports what the run installed
|
||||
# before it, whatever stopped it.
|
||||
if run is not None and run.writing and not run.listing:
|
||||
_emit_summary(run)
|
||||
raise
|
||||
|
||||
|
||||
def _install_run(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
run = _start_install(args, real_stdout)
|
||||
def _install_run(run: _InstallRun, real_stdout: TextIO) -> None:
|
||||
args = run.args
|
||||
|
||||
# Early exit for listing
|
||||
if args.list_platforms:
|
||||
|
||||
@@ -4,6 +4,8 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
from collections.abc import Iterator
|
||||
from contextlib import contextmanager
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, NoReturn, TextIO
|
||||
|
||||
@@ -108,6 +110,20 @@ class _InstallRun:
|
||||
# No setup found, the standalone emulator folders filled instead:
|
||||
# the run still ends on its summary, exit code and result.
|
||||
self.standalone_only = False
|
||||
# A step about to write was reached: a refusal from then on still
|
||||
# ends on the summary of what the run installed before it.
|
||||
self.writing = False
|
||||
|
||||
@contextmanager
|
||||
def writes(self, pending: int) -> Iterator[None]:
|
||||
"""The checks before a step writes, pending the files it would
|
||||
write, counted as still to install when a refusal stops it."""
|
||||
self.writing = True
|
||||
try:
|
||||
yield
|
||||
except Refusal:
|
||||
self.files_pending += pending
|
||||
raise
|
||||
|
||||
|
||||
def _start_install(args: argparse.Namespace, real_stdout: TextIO) -> _InstallRun:
|
||||
|
||||
@@ -202,7 +202,8 @@ def _install_standalone_folders(run: _InstallRun) -> bool:
|
||||
print(f" {EVERYTHING_IN_PLACE}")
|
||||
continue
|
||||
size = sum(entry.get("size", 0) for entry in to_download)
|
||||
_check_free_space(folder, size, code=1 if run.total_downloaded else 2)
|
||||
with run.writes(len(to_download)):
|
||||
_check_free_space(folder, size, code=1 if run.total_downloaded else 2)
|
||||
progress = Progress(len(to_download), size, term)
|
||||
failed, interrupted = download_files(
|
||||
to_download, folder, jobs=args.jobs, verbose=args.verbose,
|
||||
|
||||
@@ -10635,6 +10635,33 @@ class ScreenRowsAndFilters(unittest.TestCase):
|
||||
self.assertEqual((events[-3]["stage"], events[-3]["reason"]), ("dest", "not_writable"))
|
||||
self.assertEqual(events[-1]["code"], 2)
|
||||
|
||||
def test_a_full_drive_ends_on_an_error_and_a_summary(self):
|
||||
"""The space refusal ended on error then end: a script learned
|
||||
nothing of what the run installed, where a folder that could not
|
||||
be created gave it a summary."""
|
||||
import subprocess
|
||||
|
||||
from tests.test_install_offline import PAYLOAD, _offline_env, _pack
|
||||
|
||||
pack = _pack(self.root, "RetroArch_v1_BIOS_Pack.zip", PAYLOAD)
|
||||
argv = ["install.py", "--platform", "retroarch", "--dest", str(self.root / "system"),
|
||||
"--from-pack", str(pack), "--events"]
|
||||
program = ("import runpy, shutil, sys, types\n"
|
||||
"shutil.disk_usage = lambda _p: types.SimpleNamespace(free=1)\n"
|
||||
f"sys.argv = {argv!r}\n"
|
||||
f"runpy.run_path({str(REPO_ROOT / 'install.py')!r}, run_name='__main__')\n")
|
||||
proc = subprocess.run([sys.executable, "-c", program], env=_offline_env(),
|
||||
capture_output=True, text=True, timeout=120, check=False,
|
||||
stdin=subprocess.DEVNULL)
|
||||
events = [json.loads(line) for line in proc.stdout.splitlines()]
|
||||
kinds = [event["event"] for event in events]
|
||||
self.assertEqual(kinds[-3:], ["error", "summary", "end"], proc.stderr)
|
||||
self.assertEqual((events[-3]["stage"], events[-3]["reason"]), ("space", "drive_full"))
|
||||
self.assertEqual(events[-2]["installed"], 0)
|
||||
self.assertGreater(events[-2]["pending"], 0)
|
||||
self.assertEqual(events[-1]["code"], 2)
|
||||
self.assertFalse((self.root / "system").exists())
|
||||
|
||||
|
||||
class EdgesTheMutantsFound(unittest.TestCase):
|
||||
"""Changes to the code that every test let through: the survivors of a
|
||||
|
||||
+1
-1
@@ -2229,7 +2229,7 @@ other schemas under `api/v1/schemas/`.
|
||||
| `start` | `schema`, `installer`, `mode` | First line. `schema` is 1, `installer` the identity `--version` prints, `mode` one of `install`, `check`, `dry-run`, `list` (also `--backups`), `remove` (`--remove`, `--delete-backup`), `restore`, `pack` (`--pack`, with `--dry-run` too) |
|
||||
| `unsearched` | `folder`, `reason`, `message` | Before `detect`, once for each folder the search for setups could not look in, this user being refused it or a read failing there (a failing card, a link that loops), or under WSL the Windows side when Windows did not answer (`folder` is then the drive mount, `/mnt`). What it would hold counts as absent, and the other places are still searched: `detect` then lists what they hold, and an empty `platforms` after an `unsearched` line means nothing was found where the installer could look. `reason` says why in words (`Permission denied`), `message` says it in a sentence |
|
||||
| `detect` | `os`, `os_name`, `platforms` | Once the platforms are known. `os_name` comes from `/etc/os-release`. `platforms` lists `{platform, name, bios_dir}`, and is empty when nothing supported was found |
|
||||
| `error` | `stage`, `reason`, `platform`, `message` | The file list could not be read (`stage` is `manifest`): `reason` is `network`, `not_found` or `invalid`, `clock` when the server's certificate was refused and the system clock reads a date before the installer was written, `no_ca` when the machine holds no list of trusted certificates (`SSL_CERT_FILE` names one), `no_ssl` when this Python was built without its `ssl` module and cannot use HTTPS, or `offline` when `--offline` forbids the request. A `--manifest` file that cannot be read carries `reason` `unreadable`, and the standalone layout `--standalone` needs `unavailable`. A folder named with `--from` cannot be read (`stage` is `from`, `reason` `not_found`, `not_a_folder` for a file that is no ZIP, `unreadable`, or `system` for the root of the system, `/proc`, `/sys` or `/dev`). The BIOS folder sits under a folder this user cannot open (`stage` is `dest`, `reason` `unreadable`), or is a file or lies under one (`reason` `not_a_folder`), and the run ends with code 1 before anything is written. A platform, target, system, core or emulator named on the command line is unknown or cannot be used here (`stage` is `option`, `reason` `unknown`, `platform` the platform it was checked against or the name typed), refused before any download with code 2, or a `--find` hash no one file of the list holds (code 4). An option that does not apply to the run, `--romm-firmware` without RomM or `--installed-cores` for a system that ships its cores (`stage` is `option`, `reason` `not_applicable`), or a `--romm-firmware` value it cannot read (`reason` `invalid`), code 1. A `--remove` or `--delete-backup` without `--yes` where no question can be asked (`stage` is `option`, `reason` `needs_yes`, code 2). The list does not record what `--system`, `--core`, `--region`, `--emulator`, `--standalone`, `--source truth`, `--no-game-data`, `--installed-cores` or `--one-per-slot` reads (`stage` is `option`, `reason` `not_recorded`, code 1). `--installed-cores` finds no core (`stage` is `cores`, `reason` `none`), or its `--cores-dir` does not exist, is not a folder or cannot be read (`reason` `not_found`, `not_a_folder` or `unreadable`). The board list a run needs cannot be had (`stage` is `targets`, `reason` as for the file list, `http` for a refused answer). The `--from-pack` file is no pack, is a pack of another platform, or names no platform and none is given (`stage` is `pack`, `reason` `invalid`, `other_platform` or `no_platform`), as for a `--pack` whose name gives no platform (code 2). A `--delete-backup` folder is not one the installer kept files in (`stage` is `backup`, `reason` `not_a_backup`, code 2). The BIOS folder cannot be created (`stage` is `dest`, `reason` `not_writable`): a `summary` follows with what the run installed before it. Two systems are detected on one machine and no `--dest` names the folder, or a `--dest` given alone finds several here (`stage` is `detect`, `reason` `conflict`), as are `--remove` and `--backups` finding several setups and none named (`not_found` for none), with code 2. The platform named with `--platform` is found nowhere and no folder can be assumed for it: a card system with no card named, a portable emulator, Batocera or Recalbox named on a computer (their folder is the `bios` folder of their SHARE drive), or no usual folder on this system or one set aside behind a folder this user cannot open (`stage` is `detect`, `reason` `not_found`). So is a platform named by a file list or a pack, in a run without questions where it is found nowhere here. A `--dest` refused as the card of the system named carries the same `stage` and `reason`: another system's card, a folder inside a card, a drive with none of the files its card always has, or a folder that does not exist. The drive holding the BIOS folder cannot hold the download (`stage` is `space`, `reason` `drive_full`), right after `no_space`, before any file of the setup is written. `message` says it in words, and is the only thing that tells these cases apart |
|
||||
| `error` | `stage`, `reason`, `platform`, `message` | The file list could not be read (`stage` is `manifest`): `reason` is `network`, `not_found` or `invalid`, `clock` when the server's certificate was refused and the system clock reads a date before the installer was written, `no_ca` when the machine holds no list of trusted certificates (`SSL_CERT_FILE` names one), `no_ssl` when this Python was built without its `ssl` module and cannot use HTTPS, or `offline` when `--offline` forbids the request. A `--manifest` file that cannot be read carries `reason` `unreadable`, and the standalone layout `--standalone` needs `unavailable`. A folder named with `--from` cannot be read (`stage` is `from`, `reason` `not_found`, `not_a_folder` for a file that is no ZIP, `unreadable`, or `system` for the root of the system, `/proc`, `/sys` or `/dev`). The BIOS folder sits under a folder this user cannot open (`stage` is `dest`, `reason` `unreadable`), or is a file or lies under one (`reason` `not_a_folder`), and the run ends with code 1 before anything is written. A platform, target, system, core or emulator named on the command line is unknown or cannot be used here (`stage` is `option`, `reason` `unknown`, `platform` the platform it was checked against or the name typed), refused before any download with code 2, or a `--find` hash no one file of the list holds (code 4). An option that does not apply to the run, `--romm-firmware` without RomM or `--installed-cores` for a system that ships its cores (`stage` is `option`, `reason` `not_applicable`), or a `--romm-firmware` value it cannot read (`reason` `invalid`), code 1. A `--remove` or `--delete-backup` without `--yes` where no question can be asked (`stage` is `option`, `reason` `needs_yes`, code 2). The list does not record what `--system`, `--core`, `--region`, `--emulator`, `--standalone`, `--source truth`, `--no-game-data`, `--installed-cores` or `--one-per-slot` reads (`stage` is `option`, `reason` `not_recorded`, code 1). `--installed-cores` finds no core (`stage` is `cores`, `reason` `none`), or its `--cores-dir` does not exist, is not a folder or cannot be read (`reason` `not_found`, `not_a_folder` or `unreadable`). The board list a run needs cannot be had (`stage` is `targets`, `reason` as for the file list, `http` for a refused answer). The `--from-pack` file is no pack, is a pack of another platform, or names no platform and none is given (`stage` is `pack`, `reason` `invalid`, `other_platform` or `no_platform`), as for a `--pack` whose name gives no platform (code 2). A `--delete-backup` folder is not one the installer kept files in (`stage` is `backup`, `reason` `not_a_backup`, code 2). The BIOS folder cannot be created (`stage` is `dest`, `reason` `not_writable`). Two systems are detected on one machine and no `--dest` names the folder, or a `--dest` given alone finds several here (`stage` is `detect`, `reason` `conflict`), as are `--remove` and `--backups` finding several setups and none named (`not_found` for none), with code 2. The platform named with `--platform` is found nowhere and no folder can be assumed for it: a card system with no card named, a portable emulator, Batocera or Recalbox named on a computer (their folder is the `bios` folder of their SHARE drive), or no usual folder on this system or one set aside behind a folder this user cannot open (`stage` is `detect`, `reason` `not_found`). So is a platform named by a file list or a pack, in a run without questions where it is found nowhere here. A `--dest` refused as the card of the system named carries the same `stage` and `reason`: another system's card, a folder inside a card, a drive with none of the files its card always has, or a folder that does not exist. The drive holding the BIOS folder cannot hold the download (`stage` is `space`, `reason` `drive_full`), right after `no_space`, before any file of the setup is written. Once a setup reached its first write, its space check included, an `error` that stops the run is followed by `failures` and a `summary` of what the run installed before it, as at its end. `message` says it in words, and is the only thing that tells these cases apart |
|
||||
| `no_space` | `platform`, `folder`, `bytes_needed`, `bytes_free` | Right before the `error` of `stage` `space`: the BIOS folder, the bytes the run writes there and the bytes free on its drive. `platform` is empty for a standalone build's folder |
|
||||
| `scanned` | `folder`, `files`, `truncated`, `other_drives` | Each folder named with `--from`, once read and before `detect`. `files` counts the files found, `truncated` is true when the search stopped at 200,000 of them, and `other_drives` lists the folders below it on another drive, which were not entered |
|
||||
| `version` | `platform`, `list_version`, `installed_version`, `message` | Before `choices`, when the system here runs another version than the one the list was built for: `list_version` is the list's, `installed_version` the one the system's version file states, and `message` says it and what it means. Not written when either version is unknown. The run goes on |
|
||||
|
||||
Reference in new issue
Block a user