summaryrefslogtreecommitdiff
path: root/program/utils.py
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2021-03-29 12:22:19 (GMT)
committerChristian Pointner <equinox@helsinki.at>2021-05-28 20:17:37 (GMT)
commitdde04a95dcb76b765b8c66775a6ee242d3c316c4 (patch)
tree9dd6feef40534dae4f515dc6d24b7fc1ea29acca /program/utils.py
parent8154c30318127e0491786b65975bee808cd8e27b (diff)
add show and note images based on S3 storage
Diffstat (limited to 'program/utils.py')
-rw-r--r--program/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/program/utils.py b/program/utils.py
index 1a81766..3bfecc4 100644
--- a/program/utils.py
+++ b/program/utils.py
@@ -3,8 +3,10 @@ from django.conf import settings
import json
import urllib
import bisect
+import hashlib
from os.path import join
from datetime import datetime, date, timedelta
+from functools import partial
def get_automation_id_choices():
@@ -56,3 +58,11 @@ def tofirstdayinisoweek(year, week):
if date(year, 1, 4).isoweekday() > 4:
ret -= timedelta(days=7)
return ret
+
+
+def hash_file(file, block_size=65536):
+ hasher = hashlib.sha256()
+ for buf in iter(partial(file.read, block_size), b''):
+ hasher.update(buf)
+
+ return hasher.hexdigest()