- FastAPI backend: admin bootstrap with forced credential change, admin-created users with one-time generated passwords, roles as permission sets - Games and versions with content-addressed blob storage; forks copy only the manifest, so mods share assets with the original - Worker: archive/RPA extraction, unrpyc for .rpyc, own .rpy parser, Python subset translated via ast, media converted to WebP/Opus/WebM - React panel (library search, game page, upload, users, roles) and a framework-free web player with saves, history, skip/auto, transitions - docker compose: postgres, backend, worker, nginx on a single HTTP port Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
Python
33 lines
1.3 KiB
Python
"""Decompile .rpyc files without sources via unrpyc (best effort)."""
|
|
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
from app.config import get_settings
|
|
|
|
|
|
def decompile_missing(game_dir: Path, warn) -> int:
|
|
"""Decompile every .rpyc that has no matching .rpy. Returns how many were produced."""
|
|
pending = [p for p in game_dir.rglob("*.rpyc") if not p.with_suffix(".rpy").exists()]
|
|
if not pending:
|
|
return 0
|
|
script = get_settings().unrpyc_path
|
|
if not script.exists():
|
|
warn("unrpyc не установлен — скомпилированные скрипты (.rpyc) пропущены")
|
|
return 0
|
|
produced = 0
|
|
# several files per call keeps process start-up overhead low
|
|
for i in range(0, len(pending), 50):
|
|
batch = pending[i:i + 50]
|
|
proc = subprocess.run([sys.executable, str(script), "--try-harder", *map(str, batch)],
|
|
capture_output=True, text=True, timeout=1800)
|
|
for p in batch:
|
|
if p.with_suffix(".rpy").exists():
|
|
produced += 1
|
|
else:
|
|
warn(f"Не удалось декомпилировать {p.name}")
|
|
if proc.returncode != 0 and not any(p.with_suffix(".rpy").exists() for p in batch):
|
|
warn(f"unrpyc: {proc.stderr.strip()[-300:]}")
|
|
return produced
|