Apply linters and formatters
- frontend: oxfmt across src, fix no-useless-escape in search-worker - ruff check --fix: replace numeric rule codes with text names in pyproject.toml lint.ignore - ruff format: scanning.py, guibuild.py, release.py
This commit is contained in:
+37
-7
@@ -82,10 +82,34 @@ class _Platform(NamedTuple):
|
||||
|
||||
def _platform() -> _Platform:
|
||||
if sys.platform == "win32":
|
||||
return _Platform("win64", "win", "win-x64", "MediaHive", "mediahive.ico", "MediaHive.exe", ".exe")
|
||||
return _Platform(
|
||||
"win64",
|
||||
"win",
|
||||
"win-x64",
|
||||
"MediaHive",
|
||||
"mediahive.ico",
|
||||
"MediaHive.exe",
|
||||
".exe",
|
||||
)
|
||||
if sys.platform == "darwin":
|
||||
return _Platform("macos", "osx", "osx-arm64", "MediaHive.app", "mediahive.icns", "MediaHive", ".pkg")
|
||||
return _Platform("linux", "linux", "linux-x64", "MediaHive", "mediahive.png", "MediaHive", ".AppImage")
|
||||
return _Platform(
|
||||
"macos",
|
||||
"osx",
|
||||
"osx-arm64",
|
||||
"MediaHive.app",
|
||||
"mediahive.icns",
|
||||
"MediaHive",
|
||||
".pkg",
|
||||
)
|
||||
return _Platform(
|
||||
"linux",
|
||||
"linux",
|
||||
"linux-x64",
|
||||
"MediaHive",
|
||||
"mediahive.png",
|
||||
"MediaHive",
|
||||
".AppImage",
|
||||
)
|
||||
|
||||
|
||||
def setup_artifact_name() -> str:
|
||||
@@ -253,7 +277,7 @@ def _dotnet_runtime_major(exe: Path) -> int | None:
|
||||
result = subprocess.run(
|
||||
[str(exe), "--list-runtimes"], capture_output=True, text=True, timeout=30
|
||||
)
|
||||
except (OSError, subprocess.TimeoutExpired):
|
||||
except OSError, subprocess.TimeoutExpired:
|
||||
return None
|
||||
if result.returncode != 0:
|
||||
return None
|
||||
@@ -455,20 +479,26 @@ def force_macos_user_install(pkg: Path) -> None:
|
||||
components = list(expanded.glob("*.pkg"))
|
||||
if len(components) != 1:
|
||||
contents = sorted(p.name for p in expanded.iterdir())
|
||||
raise RuntimeError(f"Unexpected pkg layout: components={components} in {contents}")
|
||||
raise RuntimeError(
|
||||
f"Unexpected pkg layout: components={components} in {contents}"
|
||||
)
|
||||
component = components[0]
|
||||
if component.is_dir():
|
||||
comp_dir = component
|
||||
else:
|
||||
comp_dir = expanded / (component.stem + "-component")
|
||||
subprocess.run(["pkgutil", "--expand", str(component), str(comp_dir)], check=True)
|
||||
subprocess.run(
|
||||
["pkgutil", "--expand", str(component), str(comp_dir)], check=True
|
||||
)
|
||||
postinstall = comp_dir / "Scripts" / "postinstall"
|
||||
script = postinstall.read_text()
|
||||
if 'sudo -u "$USER" ' not in script:
|
||||
raise RuntimeError("Unexpected postinstall script: sudo prefix not found")
|
||||
postinstall.write_text(script.replace('sudo -u "$USER" ', ""))
|
||||
if comp_dir is not component:
|
||||
subprocess.run(["pkgutil", "--flatten", str(comp_dir), str(component)], check=True)
|
||||
subprocess.run(
|
||||
["pkgutil", "--flatten", str(comp_dir), str(component)], check=True
|
||||
)
|
||||
shutil.rmtree(comp_dir)
|
||||
|
||||
subprocess.run(["pkgutil", "--flatten", str(expanded), str(pkg)], check=True)
|
||||
|
||||
+6
-2
@@ -73,7 +73,9 @@ def load_token() -> str:
|
||||
# MediaHive-macos-setup.pkg, MediaHive-linux-setup.AppImage,
|
||||
# MediaHive-win64-portable.zip) so /releases/download/latest/<name> links
|
||||
# stay valid. The version comes from setuptools_scm instead.
|
||||
_ARTIFACT_RE = re.compile(r"^MediaHive-(?!\d)[A-Za-z0-9._-]+\.(?:zip|dmg|exe|pkg|AppImage)$")
|
||||
_ARTIFACT_RE = re.compile(
|
||||
r"^MediaHive-(?!\d)[A-Za-z0-9._-]+\.(?:zip|dmg|exe|pkg|AppImage)$"
|
||||
)
|
||||
|
||||
|
||||
def read_version() -> str:
|
||||
@@ -89,7 +91,9 @@ def read_version() -> str:
|
||||
def find_releasable_artifacts() -> list[Path]:
|
||||
"""Return platform artifact paths in build/."""
|
||||
build_dir = REPO_ROOT / "build"
|
||||
return [p for p in sorted(build_dir.glob("MediaHive-*")) if _ARTIFACT_RE.match(p.name)]
|
||||
return [
|
||||
p for p in sorted(build_dir.glob("MediaHive-*")) if _ARTIFACT_RE.match(p.name)
|
||||
]
|
||||
|
||||
|
||||
def find_dist_files(version: str) -> list[Path]:
|
||||
|
||||
Reference in New Issue
Block a user