File size: 697 Bytes
aa73ff9
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"""Verify only release files listed in SHA256SUMS.json; no inference/upload."""
import hashlib, json
from pathlib import Path
ROOT=Path(__file__).resolve().parent
def verify():
    manifest=json.loads((ROOT/'SHA256SUMS.json').read_text())
    for name,expected in manifest.items():
        path=(ROOT/name).resolve()
        if not path.is_relative_to(ROOT):raise ValueError('Invalid release path')
        with path.open('rb') as stream:actual=hashlib.file_digest(stream,'sha256').hexdigest()
        if actual!=expected:raise ValueError('Checksum mismatch: '+name)
    print('Verified',len(manifest),'release files; no inference or upload.')
    return manifest
if __name__=='__main__':verify()