webapps / hmc /reference /scripts /pack_epic_scripts.py
gdevenyi's picture
hmc: NiFreeze 3bcfb00 and QSIPrep 26.1.1 SHORELine reference runs on ds005577 sub-107 (part 9)
a4ba047 verified
Raw History Blame Contribute Delete
803 Bytes
"""Add the epic QSIPrep scripts to the packed folder and to its index.json.
Usage: python -I pack_epic_scripts.py OUT_DIR
"""
import hashlib
import json
import shutil
import sys
from pathlib import Path
SRC = Path("/var/tmp/dwi-hmc/scripts/epic")
NAMES = ("run-qsiprep.sh", "launch.sh", "pull-qsiprep.sh", "file_list.py")
out = Path(sys.argv[1])
idx_path = out / "index.json"
index = json.loads(idx_path.read_text())
for name in NAMES:
src = SRC / name
dst = out / "scripts/epic" / name
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(src, dst)
index["files"][str(dst.relative_to(out))] = {
"source": str(src),
"source_sha256": hashlib.sha256(src.read_bytes()).hexdigest(),
}
idx_path.write_text(json.dumps(index, indent=1, sort_keys=True) + "\n")