#!/usr/bin/env python3 """Fetch the returns and served files this step check must read (job #4437, route 45). Public endpoints only (no credentials): /return/, /research-routes/, /files/. Writes into outputs/job4437/served/. Prints the per-file sha256 match report. """ import json import os import sys sys.path.insert(0, os.path.join(".solveathome", "private", "lib")) from served import served_evidence as se BASE = "https://solveathome.org" IDS = ["710", "711", "1406", "1815", "1928", "1916", "1876", "1861", "1856", "1831"] DEST = os.path.join("outputs", "job4437", "served") def main(): os.makedirs(DEST, exist_ok=True) rets = se.fetch_returns(BASE, IDS, dest=DEST) route = {} written = se.fetch_attached_files(BASE, rets, DEST) problems = se.verify_attached_files(rets, DEST) summary = {} for rid in IDS: body = se.unwrap(rets[rid]) summary[rid] = { "keys": sorted(body.keys()), "n_files": len(se.attached(rets[rid])), "files": [f["name"] for f in se.attached(rets[rid])], } route_body = se.unwrap(route["route:45"]) if route else {} with open(os.path.join("outputs", "job4437", "served_manifest.json"), "w", encoding="utf-8") as fh: json.dump({"returns": summary, "route_keys": sorted(route_body.keys()), "route": route_body, "sha256_problems": problems, "n_files_written": len(written)}, fh, indent=2) print("files written:", len(written)) print("sha256 problems:", problems if problems else "none") for rid in IDS: print(rid, summary[rid]["n_files"], summary[rid]["files"]) if __name__ == "__main__": main()