mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 01:57:48 -06:00
fix: stop on one line when pyyaml is missing
This commit is contained in:
1 parent
eef13547e1
commit
7be8a7cd7b
7 files changed
+22
-30
No files matched your search
@@ -4,11 +4,6 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
yaml = None
|
||||
|
||||
from core.paths import PLATFORMS_DIR, comparable_destination
|
||||
from model.sources import source_yaml_file
|
||||
|
||||
@@ -24,9 +19,6 @@ def _inherited_yaml(platform_name: str, platforms_dir: str) -> tuple[dict, list[
|
||||
its systems, so a child's overrides rewrote the parent for the rest of
|
||||
the run.
|
||||
"""
|
||||
if yaml is None:
|
||||
raise ImportError("PyYAML required: pip install pyyaml")
|
||||
|
||||
config_file = os.path.join(platforms_dir, f"{platform_name}.yml")
|
||||
if not os.path.exists(config_file):
|
||||
raise FileNotFoundError(f"Platform config not found: {config_file}")
|
||||
|
||||
@@ -15,11 +15,6 @@ import zipfile
|
||||
from collections.abc import Callable, Iterator
|
||||
from pathlib import Path
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
yaml = None
|
||||
|
||||
from core.artifacts import file_lock as _file_lock, set_plain_mode
|
||||
from core.cli import InputMissing
|
||||
from core.github import github_token
|
||||
@@ -41,8 +36,6 @@ _TRANSIENT = (urllib.error.URLError, OSError, tarfile.TarError, zipfile.BadZipFi
|
||||
|
||||
|
||||
def load_registry(registry_path: str = DEFAULT_REGISTRY) -> dict[str, dict]:
|
||||
if yaml is None:
|
||||
raise ImportError("PyYAML required: pip install pyyaml")
|
||||
path = Path(registry_path)
|
||||
if not path.exists():
|
||||
raise InputMissing(f"Registry not found: {registry_path}")
|
||||
|
||||
@@ -18,10 +18,6 @@ import os
|
||||
from core.cli import suggest_names
|
||||
from model.cliargs import platform_arg, require_platform
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
yaml = None
|
||||
from packs.datadirs import DEFAULT_REGISTRY, load_registry, log, refresh_all, refresh_entry
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
import yaml
|
||||
from abc import ABC, abstractmethod
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
@@ -21,7 +20,12 @@ from typing import Any, Callable, NoReturn, Protocol, TypeVar
|
||||
from core.github import github_token
|
||||
from core.artifacts import copy_stream_atomic, write_text_atomic
|
||||
from core.upstream import forge_headers as upstream_headers
|
||||
from model.safeparse import yaml_load
|
||||
from model.safeparse import require_yaml, yaml_load
|
||||
|
||||
try:
|
||||
import yaml
|
||||
except ImportError:
|
||||
require_yaml() # exits with the install hint
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import logging
|
||||
import subprocess
|
||||
import sys
|
||||
@@ -37,9 +36,6 @@ def load_tracked_entries(
|
||||
|
||||
Returns {decoded_zip_name: (key, source_url)}.
|
||||
"""
|
||||
if importlib.util.find_spec("yaml") is None:
|
||||
print("Error: PyYAML required", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
with open(registry_path) as f:
|
||||
data = yaml_load(f) or {}
|
||||
entries: dict[str, tuple[str, str]] = {}
|
||||
|
||||
@@ -11,6 +11,7 @@ import pkgutil
|
||||
from abc import ABC, abstractmethod
|
||||
from pathlib import Path
|
||||
|
||||
from model.safeparse import require_yaml
|
||||
from model.sourcerevision import platform_revision
|
||||
|
||||
# Every target scraper reads the network through the platform scrapers'
|
||||
@@ -48,14 +49,10 @@ class BaseTargetScraper(ABC):
|
||||
|
||||
def write_output(self, data: dict, output_path: str) -> None:
|
||||
"""Write target data to YAML file."""
|
||||
try:
|
||||
import yaml
|
||||
except ImportError as exc:
|
||||
raise ImportError("PyYAML required: pip install pyyaml") from exc
|
||||
from core.artifacts import write_text_atomic
|
||||
|
||||
write_text_atomic(
|
||||
output_path, yaml.dump(data, default_flow_style=False, sort_keys=False)
|
||||
output_path, require_yaml().dump(data, default_flow_style=False, sort_keys=False)
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -2976,6 +2976,20 @@ class AMissingDependencyStopsTheBuild(unittest.TestCase):
|
||||
self.assertIn("PyYAML required", proc.stderr)
|
||||
self.assertFalse(output.exists())
|
||||
|
||||
def test_every_yaml_command_stops_on_one_line(self):
|
||||
"""refresh_data_dirs and check_buildbot_system ended on a traceback."""
|
||||
for command in (["scripts/refresh_data_dirs.py", "--dry-run"],
|
||||
["scripts/check_buildbot_system.py"]):
|
||||
with self.subTest(command=command[0]):
|
||||
proc = subprocess.run(
|
||||
[sys.executable, "-S", *command],
|
||||
cwd=ROOT, capture_output=True, text=True, timeout=120, check=False,
|
||||
)
|
||||
self.assertEqual(proc.returncode, 1, proc.stdout)
|
||||
self.assertEqual(
|
||||
proc.stderr.strip(), "Error: PyYAML required (pip install pyyaml)"
|
||||
)
|
||||
|
||||
def test_no_script_swallows_an_import_error(self):
|
||||
offenders = []
|
||||
for path in sorted((ROOT / "scripts").rglob("*.py")):
|
||||
|
||||
Reference in new issue
Block a user