2019-01-02 23:46:01 -05:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
"""Calculate the sha256 digest of a given file."""
|
|
|
|
|
import hashlib, os, subprocess, sys
|
|
|
|
|
|
|
|
|
|
subprocess.check_call([
|
|
|
|
|
'redo-ifchange',
|
|
|
|
|
sys.argv[2],
|
2019-05-15 15:17:29 -07:00
|
|
|
], close_fds=False)
|
2019-01-02 23:46:01 -05:00
|
|
|
|
|
|
|
|
h = hashlib.sha256()
|
2019-05-15 16:53:49 -07:00
|
|
|
f = open(sys.argv[2], 'rb')
|
2019-01-02 23:46:01 -05:00
|
|
|
while 1:
|
|
|
|
|
b = f.read(65536)
|
|
|
|
|
if not b: break
|
|
|
|
|
h.update(b)
|
|
|
|
|
open(sys.argv[3], 'w').write(h.hexdigest() + '\n')
|