mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-24 10:37:54 -06:00
fix: say why a version page or check went unread
This commit is contained in:
1 parent
dae6b3a146
commit
91e385598e
7 files changed
+91
-13
No files matched your search
@@ -623,6 +623,8 @@ def fetch_page(url: str, cache_dir: str, offline: bool) -> str | None:
|
||||
|
||||
A project published outside a forge (Altirra, mednafen, ePSXe) says its
|
||||
version on a download page: that page is the only release feed there is.
|
||||
None is a page the site answers absent. Offline, a page the cache never
|
||||
stored raises NotCachedError, as every other read of this module does.
|
||||
"""
|
||||
key = hashlib.sha256(url.encode()).hexdigest()
|
||||
target = Path(cache_dir) / "_pages" / f"{key}.txt"
|
||||
@@ -632,7 +634,7 @@ def fetch_page(url: str, cache_dir: str, offline: bool) -> str | None:
|
||||
raw = target.read_text(encoding="utf-8")
|
||||
return None if raw == ABSENT else raw
|
||||
if offline:
|
||||
return None
|
||||
raise NotCachedError(f"{url} is not in the offline cache")
|
||||
text = http_text(url)
|
||||
write_cache(target, ABSENT if text is None else text)
|
||||
return text
|
||||
|
||||
@@ -113,6 +113,13 @@ def summarize_profile_sync(report: object) -> list[Finding]:
|
||||
findings.append(Finding("profiles", name, status, local=declared,
|
||||
remote=announced, detail=detail))
|
||||
continue
|
||||
if row.get("skipped") and row.get("page_version_unread"):
|
||||
# The release page is the only feed this profile has: unread, a
|
||||
# new release cannot be told from none, so the row is unknown.
|
||||
findings.append(Finding("profiles", name, UNKNOWN,
|
||||
local=str(row.get("declared_version") or ""),
|
||||
detail=f"version page unread: {row['page_version_unread']}"))
|
||||
continue
|
||||
if row.get("skipped"):
|
||||
# A skip profile_sync counts as a defect (no repository answers,
|
||||
# no resolvable pin) is unknown. One that is the profile's nature
|
||||
|
||||
@@ -60,6 +60,10 @@ class ProfileReport:
|
||||
# (version_source): the version read there, beside the one declared.
|
||||
declared_version: str | None = None
|
||||
page_version: str | None = None
|
||||
# Why the page gave no version: not cached offline, absent, refused, or
|
||||
# the pattern no longer matches. A feed that moved is not a profile
|
||||
# without one, and check_freshness reads the difference here.
|
||||
page_version_unread: str | None = None
|
||||
# An announced version searched for and found only rebuilt or re-signed.
|
||||
no_genuine_copy: str | None = None
|
||||
# What realign_prose has to settle before a recale or a bump can run:
|
||||
@@ -71,6 +75,9 @@ class ProfileReport:
|
||||
# release, kept on the report so every output carries it.
|
||||
version: VersionReport | None = None
|
||||
version_warning: str | None = None
|
||||
# A forge that refused the version check or the tag ancestry read, kept
|
||||
# here so --json carries it as the text report does.
|
||||
version_unread: str | None = None
|
||||
# --detect-new-files and --watch-hashes, kept on the report so --json
|
||||
# carries them to check_freshness. None when not asked. A new file is
|
||||
# {path, line, name, since_pin}: since_pin when the pinned revision of
|
||||
@@ -213,6 +220,7 @@ def _report_header(report: ProfileReport) -> list[str]:
|
||||
lines.append(
|
||||
f" version page: declared {report.declared_version or '-'}, "
|
||||
f"announced {report.page_version or 'unreadable'}"
|
||||
+ (f" ({report.page_version_unread})" if report.page_version_unread else "")
|
||||
+ (" (no genuine copy found)"
|
||||
if report.page_version and report.page_version == report.no_genuine_copy
|
||||
else "")
|
||||
@@ -224,6 +232,8 @@ def _report_header(report: ProfileReport) -> list[str]:
|
||||
f"latest tag {version.latest_tag}, "
|
||||
f"latest release {version.latest_release} ({version.release_date})"
|
||||
)
|
||||
if report.version_unread:
|
||||
lines.append(f" {report.version_unread}")
|
||||
if report.version_warning:
|
||||
lines.append(f" {report.version_warning}")
|
||||
return lines
|
||||
|
||||
@@ -268,7 +268,8 @@ def _attach_version(
|
||||
"""Record core_version against the forge's latest tag and release.
|
||||
|
||||
Kept on the report rather than printed, so --json carries it as the text
|
||||
report does. A forge that refuses is named on the profile's own line.
|
||||
report does. A forge that refuses is named on the profile's own line
|
||||
(version_unread).
|
||||
"""
|
||||
repo = select_repo(profile) if report.head else None
|
||||
if repo is None:
|
||||
@@ -278,7 +279,7 @@ def _attach_version(
|
||||
except upstream.RateLimitError:
|
||||
raise
|
||||
except upstream.UpstreamError as exc:
|
||||
print(f"{report.name}: version check skipped: {exc}", file=sys.stderr)
|
||||
report.version_unread = f"version check skipped: {exc}"
|
||||
return
|
||||
relation = None
|
||||
passed = None
|
||||
@@ -295,7 +296,7 @@ def _attach_version(
|
||||
except upstream.RateLimitError:
|
||||
raise
|
||||
except upstream.UpstreamError as exc:
|
||||
print(f"{report.name}: tag ancestry unread: {exc}", file=sys.stderr)
|
||||
report.version_unread = f"tag ancestry unread: {exc}"
|
||||
newer = None
|
||||
report.version_warning = version_warning(version, report.pin, relation, passed) or (
|
||||
f"{'release' if version.latest_release else 'tag'} {newer} is newer than core_version {version.declared} and the pin: "
|
||||
@@ -425,7 +426,9 @@ def _build_full_report(
|
||||
report.stale_prose = _read_stale_prose(name, profile_path, args, failed)
|
||||
if args.check_version and profile.get("version_source"):
|
||||
report.declared_version = str(profile.get("core_version") or "") or None
|
||||
report.page_version = page_version(profile, args.cache_dir, args.offline)
|
||||
report.page_version, report.page_version_unread = page_version(
|
||||
profile, args.cache_dir, args.offline
|
||||
)
|
||||
report.no_genuine_copy = str(
|
||||
profile["version_source"].get("no_genuine_copy") or "") or None
|
||||
if args.check_version:
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
from dataclasses import dataclass
|
||||
|
||||
from core import upstream
|
||||
@@ -40,23 +39,31 @@ def check_version(
|
||||
)
|
||||
|
||||
|
||||
def page_version(profile: dict, cache_dir: str, offline: bool) -> str | None:
|
||||
def page_version(
|
||||
profile: dict, cache_dir: str, offline: bool
|
||||
) -> tuple[str | None, str | None]:
|
||||
"""The latest version a profile's version_source page announces.
|
||||
|
||||
Forty-odd profiles live off any forge: profile_sync could only say
|
||||
"unsupported host", and a new Altirra or mednafen release went unseen.
|
||||
Returns (version, None) or (None, why the page gave no version): a page
|
||||
not cached offline, absent, refused, or one the pattern no longer finds.
|
||||
One None for all four read like a profile with no version_source.
|
||||
"""
|
||||
source = profile.get("version_source") or {}
|
||||
url, pattern = str(source.get("url") or ""), str(source.get("pattern") or "")
|
||||
if not url or not pattern:
|
||||
return None
|
||||
return None, "version_source names no url or pattern"
|
||||
try:
|
||||
text = upstream.fetch_page(url, cache_dir, offline)
|
||||
except upstream.NotCachedError:
|
||||
return None, "not cached offline"
|
||||
except upstream.UpstreamError as exc:
|
||||
print(f"{profile.get('emulator', '?')}: {url}: {exc}", file=sys.stderr)
|
||||
return None
|
||||
match = re.search(pattern, text or "")
|
||||
return match.group(1) if match else None
|
||||
return None, f"{url}: {exc}"
|
||||
if text is None:
|
||||
return None, "page absent"
|
||||
match = re.search(pattern, text)
|
||||
return (match.group(1), None) if match else (None, "pattern not found")
|
||||
|
||||
|
||||
def version_warning(
|
||||
|
||||
Reference in new issue
Block a user