File size: 803 Bytes
a4ba047
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""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")