mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 22:38:54 -06:00
refactor: split core.upstream by subject
HTTP to the forges moves to core.forgehttp, comparisons, trees and clone history to core.upstreamtree. core.upstream keeps repositories, the cache and revisions.
This commit is contained in:
1 parent
ce92eff0aa
commit
263a64c0e0
65 files changed
+1417
-1337
No files matched your search
@@ -10,6 +10,7 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core import forgehttp
|
||||
from core.paths import REPO_ROOT
|
||||
from scripts.scraper import game_dat_importer
|
||||
from scripts.scraper.dat_fetch import is_tracked_dat, label_version
|
||||
@@ -109,7 +110,7 @@ def redump_datfile_version(code: str) -> str:
|
||||
gives the download: a HEAD request, nothing downloaded."""
|
||||
url = game_dat_importer.REDUMP_DATFILE_URL.format(code=code)
|
||||
request = urllib.request.Request(url, method="HEAD", headers={"User-Agent": "retrobios/1.0"})
|
||||
disposition = upstream.open_retrying(
|
||||
disposition = forgehttp.open_retrying(
|
||||
request, lambda response: response.headers.get("Content-Disposition", ""), timeout=60
|
||||
)
|
||||
version = game_dat_importer.served_version(game_dat_importer.datfile_name(disposition) or "")
|
||||
@@ -135,7 +136,7 @@ def _check_redump_games(offline: bool) -> Finding:
|
||||
for code, (_name, system, _floor) in sorted(game_dat_importer.REDUMP_DATS.items()):
|
||||
try:
|
||||
remote = redump_datfile_version(code)
|
||||
except (OSError, http.client.HTTPException, upstream.UpstreamError, ValueError) as exc:
|
||||
except (OSError, http.client.HTTPException, forgehttp.UpstreamError, ValueError) as exc:
|
||||
return Finding("catalogs", subject, UNKNOWN, local=newest, detail=str(exc))
|
||||
remote_newest = max(remote_newest, remote)
|
||||
if local.get(system) != remote:
|
||||
@@ -194,8 +195,8 @@ def _check_tosec(offline: bool) -> Finding:
|
||||
if offline:
|
||||
return Finding("catalogs", "tosec", SKIPPED, local=imported, detail="offline")
|
||||
try:
|
||||
html = upstream.http_text(TOSEC_DOWNLOADS)
|
||||
except upstream.UpstreamError as exc:
|
||||
html = forgehttp.http_text(TOSEC_DOWNLOADS)
|
||||
except forgehttp.UpstreamError as exc:
|
||||
return Finding("catalogs", "tosec", UNKNOWN, local=imported, detail=str(exc))
|
||||
latest = tosec_latest_pack(html or "")
|
||||
if latest is None:
|
||||
|
||||
@@ -6,6 +6,7 @@ import json
|
||||
import re
|
||||
|
||||
from core import upstream
|
||||
from core import forgehttp
|
||||
from core.paths import REPO_ROOT
|
||||
from installer_build import pins as installer_build_pins
|
||||
from freshness.findings import INSTALLER_PIN, OK, SKIPPED, STALE, UNKNOWN, Finding
|
||||
@@ -76,7 +77,7 @@ def specifier_allows(spec: str, version: str) -> bool:
|
||||
|
||||
|
||||
def pypi_latest(name: str) -> str | None:
|
||||
payload = upstream.http_json(PYPI_URL.format(name=name))
|
||||
payload = forgehttp.http_json(PYPI_URL.format(name=name))
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
info = payload.get("info") or {}
|
||||
@@ -93,7 +94,7 @@ def parse_npm_pins(text: str) -> dict[str, str]:
|
||||
|
||||
|
||||
def npm_latest(name: str) -> str | None:
|
||||
payload = upstream.http_json(NPM_URL.format(name=name))
|
||||
payload = forgehttp.http_json(NPM_URL.format(name=name))
|
||||
if not isinstance(payload, dict):
|
||||
return None
|
||||
return str(payload.get("version") or "") or None
|
||||
@@ -110,7 +111,7 @@ def _npm_findings() -> list[Finding]:
|
||||
continue
|
||||
try:
|
||||
latest = npm_latest(name)
|
||||
except upstream.UpstreamError as exc:
|
||||
except forgehttp.UpstreamError as exc:
|
||||
findings.append(Finding("ci", subject, UNKNOWN, local=pinned, detail=str(exc)))
|
||||
continue
|
||||
if latest is None:
|
||||
@@ -147,7 +148,7 @@ def check_ci(cache_dir: str, offline: bool) -> list[Finding]:
|
||||
for name, spec in sorted(pins.items()):
|
||||
try:
|
||||
latest = pypi_latest(name)
|
||||
except upstream.UpstreamError as exc:
|
||||
except forgehttp.UpstreamError as exc:
|
||||
findings.append(Finding("ci", f"pypi:{name}", UNKNOWN, local=spec, detail=str(exc)))
|
||||
continue
|
||||
if latest is None:
|
||||
|
||||
@@ -6,6 +6,8 @@ import re
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core import forgehttp
|
||||
from core import upstreamtree
|
||||
from model.sourcerevision import scraped_revision
|
||||
from freshness.findings import OK, SHOWN_NAMES, SKIPPED, STALE, UNKNOWN, Finding
|
||||
|
||||
@@ -89,17 +91,17 @@ def check_pin_builds(
|
||||
# platform's tree pins: KNULLI builds Batocera's
|
||||
# amiberry package through its batocera submodule.
|
||||
modules = upstream.fetch_file(repo, at, ".gitmodules", cache_dir, offline)
|
||||
declared = upstream.submodule_urls("\n".join(modules or ()), repo)
|
||||
declared = upstreamtree.submodule_urls("\n".join(modules or ()), repo)
|
||||
if any(reference["path"].startswith(f"{p}/") for p in declared):
|
||||
linked = upstream.through_gitlink(repo, at, reference["path"],
|
||||
linked = upstreamtree.through_gitlink(repo, at, reference["path"],
|
||||
cache_dir, offline)
|
||||
if linked is not None:
|
||||
lines = upstream.fetch_file(*linked, cache_dir, offline)
|
||||
except upstream.NotCachedError:
|
||||
except forgehttp.NotCachedError:
|
||||
findings.append(Finding("profiles", subject, SKIPPED, local=recorded[:12],
|
||||
detail="offline, the build file is not cached"))
|
||||
continue
|
||||
except upstream.UpstreamError as exc:
|
||||
except forgehttp.UpstreamError as exc:
|
||||
findings.append(Finding("profiles", subject, UNKNOWN, local=recorded[:12],
|
||||
detail=str(exc)))
|
||||
continue
|
||||
|
||||
@@ -7,7 +7,7 @@ import subprocess
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core import forgehttp
|
||||
from model.registry import list_registered_platforms, load_platform_registry
|
||||
from model.sources import source_yaml_file
|
||||
from freshness.findings import ERROR, OK, SKIPPED, STALE, UNKNOWN, Finding
|
||||
@@ -96,9 +96,9 @@ def check_emulatorjs(platforms_dir: Path, offline: bool) -> Finding:
|
||||
tag = str((source_yaml_file(platforms_dir / "romm.yml") or {}).get("version", ""))
|
||||
for path in ROMM_DOCKERFILES:
|
||||
try:
|
||||
text = upstream.http_text(
|
||||
text = forgehttp.http_text(
|
||||
f"https://raw.githubusercontent.com/rommapp/romm/{tag}/{path}")
|
||||
except upstream.UpstreamError as exc:
|
||||
except forgehttp.UpstreamError as exc:
|
||||
return Finding("platforms", subject, UNKNOWN, local=local, detail=str(exc))
|
||||
pin = emulatorjs_pin(text or "")
|
||||
if pin:
|
||||
|
||||
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core import upstreamtree
|
||||
from model.registry import load_platform_registry
|
||||
from model.romfolders import load_sources, row_sources, sources_dir
|
||||
from model.sourcerevision import scraped_revision
|
||||
@@ -115,6 +116,6 @@ def _romfolder_upstream(
|
||||
return Finding("romfolders", subject, UNKNOWN, local=pin, detail="branch head unavailable")
|
||||
if head == commit:
|
||||
return Finding("romfolders", subject, OK, local=pin, detail="branch head")
|
||||
counts = upstream.ancestry(repo, commit, head, cache_dir)
|
||||
counts = upstreamtree.ancestry(repo, commit, head, cache_dir)
|
||||
behind = f"{counts[0]} commits behind the branch head" if counts else "the branch head moved"
|
||||
return Finding("romfolders", subject, STALE, local=pin, remote=head[:12], detail=behind)
|
||||
@@ -9,6 +9,7 @@ from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
from core import upstream
|
||||
from core import forgehttp
|
||||
from model.profiles import upstream_profile_index
|
||||
from model.sources import source_yaml_file
|
||||
from model.targets import apply_target_overrides, platform_overrides, read_target_overrides
|
||||
@@ -152,7 +153,7 @@ def check_lakka_release(platforms_dir: Path, cache_dir: str, offline: bool) -> F
|
||||
repo = upstream.parse_repo(f"https://github.com/{LAKKA_REPO}")
|
||||
try:
|
||||
release = upstream.latest_release(repo, cache_dir) if repo else None
|
||||
except upstream.UpstreamError as exc:
|
||||
except forgehttp.UpstreamError as exc:
|
||||
return Finding("targets", subject, UNKNOWN, local=local, detail=str(exc))
|
||||
if release is None:
|
||||
return Finding("targets", subject, UNKNOWN, local=local, detail="no release listed")
|
||||
|
||||
Reference in new issue
Block a user