diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-09-22 18:35:47 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-09-22 18:35:47 +0200 |
| commit | cac85412d757b6054436dc9c63d30db645bc93ea (patch) | |
| tree | 1858c4eefee907a1cc7c2031fdf7d0fd4f0fdb4c /src/util.py | |
| parent | cbc497138d1c4b77860e54304705cc157c2b800a (diff) | |
| download | allocbench-cac85412d757b6054436dc9c63d30db645bc93ea.tar.gz allocbench-cac85412d757b6054436dc9c63d30db645bc93ea.zip | |
Add ArchiveArtifacts
ArchiveArtifacts check a downloaded archive against a provided checksum.
The Archive is downloaded to cache/<name>/<name>.<format>.
The only suported format is tar.
ArchiveArtifacts can be used as sources of an Allocator.
Diffstat (limited to 'src/util.py')
| -rw-r--r-- | src/util.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util.py b/src/util.py index 027cbcb..8b9e585 100644 --- a/src/util.py +++ b/src/util.py @@ -17,6 +17,7 @@ """Helper functions for allocbench""" +import hashlib import os import subprocess import sys @@ -173,3 +174,13 @@ def print_version_and_exit(): print(f"{commit}{dirty}") exit(0) + +def sha1sum(filename): + """Return sha1sum of a file""" + sha1 = hashlib.sha1() + barray = bytearray(64*1024) + view = memoryview(barray) + with open(filename, 'rb', buffering=0) as f: + for n in iter(lambda : f.readinto(view), 0): + sha1.update(view[:n]) + return sha1.hexdigest() |
