mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 06:18:51 -06:00
fix: standalone-only runs end on their summary
This commit is contained in:
1 parent
d0a7dae589
commit
58b4842c3f
8 files changed
+109
-84
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 = "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa"
|
||||
$defaultInstallSha256 = "a4501933c777d4c370341b73d96d2e8982ab8045c8ac3c7faeaea62857a8ea88"
|
||||
# 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
|
||||
|
||||
+38
-36
@@ -23049,14 +23049,14 @@ def _check_standalone_folder(to_download: list[dict], mismatched: list[dict],
|
||||
|
||||
|
||||
def preview_standalone(plan: list[tuple[Path, list[dict]]], args: argparse.Namespace,
|
||||
term: Terminal) -> int:
|
||||
term: Terminal) -> tuple[int, int]:
|
||||
"""--check or --dry-run over the emulator folders of a standalone plan:
|
||||
what each holds and lacks, or what a run would write. The count of the
|
||||
files not in place."""
|
||||
pending = 0
|
||||
files not in place, and of those in place."""
|
||||
pending = in_place = 0
|
||||
for folder, entries in plan:
|
||||
print(f"\n{folder}:")
|
||||
to_download, _up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download, up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download.extend(mismatched)
|
||||
if args.check:
|
||||
_check_standalone_folder(to_download, mismatched, args.verbose)
|
||||
@@ -23064,17 +23064,18 @@ def preview_standalone(plan: list[tuple[Path, list[dict]]], args: argparse.Names
|
||||
_print_plan(to_download, folder, term, kept=plan_kept(mismatched, folder),
|
||||
verbose=args.verbose)
|
||||
pending += len(to_download)
|
||||
return pending
|
||||
in_place += len(up_to_date)
|
||||
return pending, in_place
|
||||
|
||||
|
||||
def _install_standalone_folders(
|
||||
args: argparse.Namespace, os_type: str, term: Terminal, interactive: bool,
|
||||
) -> bool:
|
||||
"""Fill the standalone emulator folders found here, with no platform.
|
||||
def _install_standalone_folders(run: _InstallRun) -> bool:
|
||||
"""Fill the standalone emulator folders found here, with no platform,
|
||||
their counts kept in the run's totals: the run ends as every run does.
|
||||
|
||||
False when this machine has none, the run then going on to the platform
|
||||
question or hint.
|
||||
"""
|
||||
args, os_type, term = run.args, run.os_type, run.term
|
||||
if offline_requested():
|
||||
# Their folders are named by file lists this run cannot fetch: the
|
||||
# first refusal ended an --offline run that asked nothing of EmuDeck
|
||||
@@ -23089,48 +23090,44 @@ def _install_standalone_folders(
|
||||
print(" Found standalone emulator folders:")
|
||||
for folder, entries in plan:
|
||||
print(f" {folder} {_sized(entries)}")
|
||||
if interactive and not (args.check or args.dry_run or args.yes) and not _confirm(
|
||||
if run.interactive and not (args.check or args.dry_run or args.yes) and not _confirm(
|
||||
"\nInstall the BIOS files these emulators read into their folders? [Y/n] "
|
||||
):
|
||||
return False
|
||||
run.installed_paths = [folder for folder, _entries in plan]
|
||||
if args.check or args.dry_run:
|
||||
pending = preview_standalone(plan, args, term)
|
||||
if args.check and pending:
|
||||
print("\n" + _check_fetch_line(pending, "its folder"))
|
||||
sys.exit(3)
|
||||
pending, in_place = preview_standalone(plan, args, term)
|
||||
if args.check:
|
||||
run.check_pending += pending
|
||||
run.total_verified += in_place
|
||||
if pending:
|
||||
print("\n" + _check_fetch_line(pending, "its folder"))
|
||||
else:
|
||||
run.files_pending += pending
|
||||
return True
|
||||
downloaded = up_to_date_count = errors = 0
|
||||
failures: list[tuple[str, str]] = []
|
||||
transferred, seconds = 0, 0.0
|
||||
interrupted = False
|
||||
for folder, entries in plan:
|
||||
print(f"\n{folder}:")
|
||||
to_download, up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download.extend(mismatched)
|
||||
up_to_date_count += len(up_to_date)
|
||||
run.total_up_to_date += len(up_to_date)
|
||||
if not to_download:
|
||||
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 downloaded else 2)
|
||||
_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,
|
||||
term=term, progress=progress,
|
||||
)
|
||||
downloaded += progress.installed
|
||||
errors += len(failed)
|
||||
failures.extend((str(folder / dest), reason) for dest, reason in failed)
|
||||
transferred += progress.transferred()
|
||||
seconds += progress.elapsed()
|
||||
run.total_downloaded += progress.installed
|
||||
run.total_errors += len(failed)
|
||||
run.failures.extend((str(folder / dest), reason) for dest, reason in failed)
|
||||
run.total_bytes += progress.transferred()
|
||||
run.total_seconds += progress.elapsed()
|
||||
if interrupted:
|
||||
run.total_interrupted = True
|
||||
break
|
||||
_report_outcome(
|
||||
[folder for folder, _entries in plan], downloaded, up_to_date_count, errors,
|
||||
0, interrupted,
|
||||
details=OutcomeDetails(failures=failures, transferred=transferred, seconds=seconds),
|
||||
term=term,
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
@@ -23320,6 +23317,9 @@ class _InstallRun:
|
||||
self.categorized = False
|
||||
# The BIOS folders read for misplaced files, one per platform.
|
||||
self.bios_indexes: list[FolderIndex] = []
|
||||
# No setup found, the standalone emulator folders filled instead:
|
||||
# the run still ends on its summary, exit code and result.
|
||||
self.standalone_only = False
|
||||
|
||||
|
||||
def _start_install(args: argparse.Namespace, real_stdout: TextIO) -> _InstallRun:
|
||||
@@ -23518,7 +23518,8 @@ def _detect_named_setup(run: _InstallRun, named: str) -> list[tuple[str, Path]]:
|
||||
|
||||
def _nothing_detected(run: _InstallRun) -> bool:
|
||||
"""No setup found and none named: the standalone folders, a question or
|
||||
a stop. True when the run is over."""
|
||||
a stop. True when no setup is left to install (run.standalone_only
|
||||
then says the run still ends on its result)."""
|
||||
args, os_type = run.args, run.os_type
|
||||
# The screen's words where a person answers: "platform" was said
|
||||
# nowhere else.
|
||||
@@ -23530,9 +23531,8 @@ def _nothing_detected(run: _InstallRun) -> bool:
|
||||
# PCSX2 was sent to RetroArch's folder, which nothing here reads.
|
||||
narrowing = (args.system or args.core or args.emulator or args.region
|
||||
or args.target or args.installed_cores or args.declared_only)
|
||||
if not run.listing and not narrowing and _install_standalone_folders(
|
||||
args, os_type, run.term, run.interactive
|
||||
):
|
||||
if not run.listing and not narrowing and _install_standalone_folders(run):
|
||||
run.standalone_only = True
|
||||
return True
|
||||
if not run.interactive or run.listing:
|
||||
asked = next((flag for flag, on in (
|
||||
@@ -24269,7 +24269,7 @@ def _pass_standalone_preview(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
if not plan:
|
||||
return
|
||||
print("\nStandalone emulators:")
|
||||
pending = preview_standalone(plan, run.args, run.term)
|
||||
pending, _in_place = preview_standalone(plan, run.args, run.term)
|
||||
if run.args.check:
|
||||
run.check_pending += pending
|
||||
else:
|
||||
@@ -24407,6 +24407,8 @@ def _install_run(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
return
|
||||
|
||||
if _detect_setups(run):
|
||||
if run.standalone_only:
|
||||
_finish_install(run, real_stdout)
|
||||
return
|
||||
_choose_setups(run)
|
||||
|
||||
|
||||
+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="d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa"
|
||||
DEFAULT_INSTALL_SHA256="a4501933c777d4c370341b73d96d2e8982ab8045c8ac3c7faeaea62857a8ea88"
|
||||
# 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": 1487717,
|
||||
"sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa",
|
||||
"size": 1488077,
|
||||
"sha256": "a4501933c777d4c370341b73d96d2e8982ab8045c8ac3c7faeaea62857a8ea88",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -71,8 +71,8 @@
|
||||
"muos": {
|
||||
"archive": {
|
||||
"dest": "ARCHIVE/RetroBIOS.muxapp",
|
||||
"size": 1541342,
|
||||
"sha256": "621a0d612b8763db6cb42d281bcf0c4c9d97475c8e8d7400d2f34c4affe4c02d"
|
||||
"size": 1541702,
|
||||
"sha256": "e98b6819531cb50091b32a89acc65016bfa929b12a39b7b4937b5b3068767422"
|
||||
},
|
||||
"members": [
|
||||
{
|
||||
@@ -92,8 +92,8 @@
|
||||
{
|
||||
"name": "RetroBIOS/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1487717,
|
||||
"sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa",
|
||||
"size": 1488077,
|
||||
"sha256": "a4501933c777d4c370341b73d96d2e8982ab8045c8ac3c7faeaea62857a8ea88",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
@@ -166,8 +166,8 @@
|
||||
{
|
||||
"dest": ".config/modules/retrobios/install.py",
|
||||
"repo_path": "install.py",
|
||||
"size": 1487717,
|
||||
"sha256": "d22f3e21b4552873934cb50f09d44fca59d567c561d3654f8408e434c8060aaa",
|
||||
"size": 1488077,
|
||||
"sha256": "a4501933c777d4c370341b73d96d2e8982ab8045c8ac3c7faeaea62857a8ea88",
|
||||
"executable": false
|
||||
},
|
||||
{
|
||||
|
||||
+3
-1
@@ -672,7 +672,7 @@ def _pass_standalone_preview(run: _InstallRun, p: _PlatformPass) -> None:
|
||||
if not plan:
|
||||
return
|
||||
print("\nStandalone emulators:")
|
||||
pending = preview_standalone(plan, run.args, run.term)
|
||||
pending, _in_place = preview_standalone(plan, run.args, run.term)
|
||||
if run.args.check:
|
||||
run.check_pending += pending
|
||||
else:
|
||||
@@ -810,6 +810,8 @@ def _install_run(args: argparse.Namespace, real_stdout: TextIO) -> None:
|
||||
return
|
||||
|
||||
if _detect_setups(run):
|
||||
if run.standalone_only:
|
||||
_finish_install(run, real_stdout)
|
||||
return
|
||||
_choose_setups(run)
|
||||
|
||||
|
||||
@@ -105,6 +105,9 @@ class _InstallRun:
|
||||
self.categorized = False
|
||||
# The BIOS folders read for misplaced files, one per platform.
|
||||
self.bios_indexes: list[FolderIndex] = []
|
||||
# No setup found, the standalone emulator folders filled instead:
|
||||
# the run still ends on its summary, exit code and result.
|
||||
self.standalone_only = False
|
||||
|
||||
|
||||
def _start_install(args: argparse.Namespace, real_stdout: TextIO) -> _InstallRun:
|
||||
@@ -303,7 +306,8 @@ def _detect_named_setup(run: _InstallRun, named: str) -> list[tuple[str, Path]]:
|
||||
|
||||
def _nothing_detected(run: _InstallRun) -> bool:
|
||||
"""No setup found and none named: the standalone folders, a question or
|
||||
a stop. True when the run is over."""
|
||||
a stop. True when no setup is left to install (run.standalone_only
|
||||
then says the run still ends on its result)."""
|
||||
args, os_type = run.args, run.os_type
|
||||
# The screen's words where a person answers: "platform" was said
|
||||
# nowhere else.
|
||||
@@ -315,9 +319,8 @@ def _nothing_detected(run: _InstallRun) -> bool:
|
||||
# PCSX2 was sent to RetroArch's folder, which nothing here reads.
|
||||
narrowing = (args.system or args.core or args.emulator or args.region
|
||||
or args.target or args.installed_cores or args.declared_only)
|
||||
if not run.listing and not narrowing and _install_standalone_folders(
|
||||
args, os_type, run.term, run.interactive
|
||||
):
|
||||
if not run.listing and not narrowing and _install_standalone_folders(run):
|
||||
run.standalone_only = True
|
||||
return True
|
||||
if not run.interactive or run.listing:
|
||||
asked = next((flag for flag, on in (
|
||||
|
||||
+30
-33
@@ -4,7 +4,6 @@ from __future__ import annotations
|
||||
import argparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path, PurePosixPath
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
@@ -15,13 +14,14 @@ from installer.host_fs import NOT_WRITABLE, _closed_to_this_user, _exists, _is_d
|
||||
from installer.invocation import offline_requested
|
||||
from installer.lists import fetch_manifest
|
||||
from installer.local_check import check_local, unreachable_words
|
||||
from installer.outcome import EVERYTHING_IN_PLACE, OutcomeDetails, _check_fetch_line, _report_outcome
|
||||
from installer.outcome import EVERYTHING_IN_PLACE, _check_fetch_line
|
||||
from installer.paths import _destination_path, _within
|
||||
from installer.plan import _check_free_space, _print_plan
|
||||
from installer.plan_words import _sized
|
||||
from installer.safe_replace import KEPT, NOT_KEPT, _NotKept, plan_kept
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from installer.run_setups import _InstallRun
|
||||
from installer.terminal import Terminal
|
||||
|
||||
|
||||
@@ -137,14 +137,14 @@ def _check_standalone_folder(to_download: list[dict], mismatched: list[dict],
|
||||
|
||||
|
||||
def preview_standalone(plan: list[tuple[Path, list[dict]]], args: argparse.Namespace,
|
||||
term: Terminal) -> int:
|
||||
term: Terminal) -> tuple[int, int]:
|
||||
"""--check or --dry-run over the emulator folders of a standalone plan:
|
||||
what each holds and lacks, or what a run would write. The count of the
|
||||
files not in place."""
|
||||
pending = 0
|
||||
files not in place, and of those in place."""
|
||||
pending = in_place = 0
|
||||
for folder, entries in plan:
|
||||
print(f"\n{folder}:")
|
||||
to_download, _up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download, up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download.extend(mismatched)
|
||||
if args.check:
|
||||
_check_standalone_folder(to_download, mismatched, args.verbose)
|
||||
@@ -152,17 +152,18 @@ def preview_standalone(plan: list[tuple[Path, list[dict]]], args: argparse.Names
|
||||
_print_plan(to_download, folder, term, kept=plan_kept(mismatched, folder),
|
||||
verbose=args.verbose)
|
||||
pending += len(to_download)
|
||||
return pending
|
||||
in_place += len(up_to_date)
|
||||
return pending, in_place
|
||||
|
||||
|
||||
def _install_standalone_folders(
|
||||
args: argparse.Namespace, os_type: str, term: Terminal, interactive: bool,
|
||||
) -> bool:
|
||||
"""Fill the standalone emulator folders found here, with no platform.
|
||||
def _install_standalone_folders(run: _InstallRun) -> bool:
|
||||
"""Fill the standalone emulator folders found here, with no platform,
|
||||
their counts kept in the run's totals: the run ends as every run does.
|
||||
|
||||
False when this machine has none, the run then going on to the platform
|
||||
question or hint.
|
||||
"""
|
||||
args, os_type, term = run.args, run.os_type, run.term
|
||||
if offline_requested():
|
||||
# Their folders are named by file lists this run cannot fetch: the
|
||||
# first refusal ended an --offline run that asked nothing of EmuDeck
|
||||
@@ -177,48 +178,44 @@ def _install_standalone_folders(
|
||||
print(" Found standalone emulator folders:")
|
||||
for folder, entries in plan:
|
||||
print(f" {folder} {_sized(entries)}")
|
||||
if interactive and not (args.check or args.dry_run or args.yes) and not _confirm(
|
||||
if run.interactive and not (args.check or args.dry_run or args.yes) and not _confirm(
|
||||
"\nInstall the BIOS files these emulators read into their folders? [Y/n] "
|
||||
):
|
||||
return False
|
||||
run.installed_paths = [folder for folder, _entries in plan]
|
||||
if args.check or args.dry_run:
|
||||
pending = preview_standalone(plan, args, term)
|
||||
if args.check and pending:
|
||||
print("\n" + _check_fetch_line(pending, "its folder"))
|
||||
sys.exit(3)
|
||||
pending, in_place = preview_standalone(plan, args, term)
|
||||
if args.check:
|
||||
run.check_pending += pending
|
||||
run.total_verified += in_place
|
||||
if pending:
|
||||
print("\n" + _check_fetch_line(pending, "its folder"))
|
||||
else:
|
||||
run.files_pending += pending
|
||||
return True
|
||||
downloaded = up_to_date_count = errors = 0
|
||||
failures: list[tuple[str, str]] = []
|
||||
transferred, seconds = 0, 0.0
|
||||
interrupted = False
|
||||
for folder, entries in plan:
|
||||
print(f"\n{folder}:")
|
||||
to_download, up_to_date, mismatched = check_local(entries, folder, jobs=args.jobs)
|
||||
to_download.extend(mismatched)
|
||||
up_to_date_count += len(up_to_date)
|
||||
run.total_up_to_date += len(up_to_date)
|
||||
if not to_download:
|
||||
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 downloaded else 2)
|
||||
_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,
|
||||
term=term, progress=progress,
|
||||
)
|
||||
downloaded += progress.installed
|
||||
errors += len(failed)
|
||||
failures.extend((str(folder / dest), reason) for dest, reason in failed)
|
||||
transferred += progress.transferred()
|
||||
seconds += progress.elapsed()
|
||||
run.total_downloaded += progress.installed
|
||||
run.total_errors += len(failed)
|
||||
run.failures.extend((str(folder / dest), reason) for dest, reason in failed)
|
||||
run.total_bytes += progress.transferred()
|
||||
run.total_seconds += progress.elapsed()
|
||||
if interrupted:
|
||||
run.total_interrupted = True
|
||||
break
|
||||
_report_outcome(
|
||||
[folder for folder, _entries in plan], downloaded, up_to_date_count, errors,
|
||||
0, interrupted,
|
||||
details=OutcomeDetails(failures=failures, transferred=transferred, seconds=seconds),
|
||||
term=term,
|
||||
)
|
||||
return True
|
||||
|
||||
|
||||
|
||||
@@ -6399,6 +6399,27 @@ class StandaloneEmulatorsWithoutAPlatformAreServed(unittest.TestCase, _LoopbackR
|
||||
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
|
||||
self.assertIn("Every file on the list is in place.", proc.stdout)
|
||||
|
||||
def test_the_run_ends_on_its_summary(self):
|
||||
"""--check --events gave code 3 and only start, detect and end: no
|
||||
summary, so no pending, installed or failed to read."""
|
||||
proc = _install_run(self.env, "--no-input", "--check", "--events")
|
||||
self.assertEqual(proc.returncode, 3, proc.stdout + proc.stderr)
|
||||
events = [json.loads(line) for line in proc.stdout.splitlines()
|
||||
if line.startswith("{")]
|
||||
summary = [event for event in events if event["event"] == "summary"]
|
||||
self.assertEqual(len(summary), 1, events)
|
||||
self.assertEqual(summary[0]["mode"], "check")
|
||||
self.assertGreater(summary[0]["pending"], 0)
|
||||
self.assertEqual(events[-1], {"event": "end", "code": 3})
|
||||
proc = _install_run(self.env, "--no-input", "--events")
|
||||
self.assertEqual(proc.returncode, 0, proc.stdout + proc.stderr)
|
||||
events = [json.loads(line) for line in proc.stdout.splitlines()
|
||||
if line.startswith("{")]
|
||||
summary = [event for event in events if event["event"] == "summary"]
|
||||
self.assertEqual(len(summary), 1, events)
|
||||
self.assertGreater(summary[0]["installed"], 0)
|
||||
self.assertEqual(summary[0]["pending"], 0)
|
||||
|
||||
def test_no_emulator_folder_keeps_the_hint(self):
|
||||
self.duckstation.rmdir()
|
||||
proc = _install_run(self.env, "--no-input")
|
||||
|
||||
Reference in new issue
Block a user