Answer stability round 1: 0 🔴, 4 🟡 (0 misread); count chunks and projects as the archive holds them, date the 876 commits, fail the print when a font fails to load, build the image under run-heavy, and print from Python
This commit is contained in:
Executable
+28
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Print index.html to loop-claude-explained.pdf beside it, in the playwright-for-claude image."""
|
||||
import pathlib, shutil, subprocess, sys, tempfile
|
||||
|
||||
HERE = pathlib.Path(__file__).resolve().parent
|
||||
IMAGE = "playwright-for-claude"
|
||||
# index.html is an artifact body, without a doctype, head or body of its own, so wrap it as the artifact host does.
|
||||
HEAD = '<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><style>:root{color-scheme:light}body{margin:0}img{max-width:100%}[hidden]{display:none!important}</style></head><body>\n'
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if subprocess.run(["docker", "image", "inspect", IMAGE], capture_output=True).returncode != 0:
|
||||
print(f"No {IMAGE} image. Build it once with: ~/.claude/bin/run-heavy docker build -t {IMAGE} ~/code/playwright-for-agents", file=sys.stderr)
|
||||
return 1
|
||||
with tempfile.TemporaryDirectory() as folder:
|
||||
work = pathlib.Path(folder)
|
||||
(work / "page.html").write_text(HEAD + (HERE / "index.html").read_text(encoding="utf-8") + "</body></html>\n", encoding="utf-8")
|
||||
shutil.copy(HERE / "render-pdf.js", work)
|
||||
printed = subprocess.run(["docker", "run", "--rm", "--init", "--memory", "2g", "--memory-swap", "2g", "-v", f"{work}:/work", "-w", "/work", "--entrypoint", "node", IMAGE, "render-pdf.js"])
|
||||
if printed.returncode != 0:
|
||||
return printed.returncode
|
||||
shutil.copy(work / "out.pdf", HERE / "loop-claude-explained.pdf")
|
||||
print(f"Wrote {HERE / 'loop-claude-explained.pdf'}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user