Merge branch 'load_modules' into add_module_tests

# Conflicts:
#	src/auto_archiver/modules/s3_storage/s3_storage.py
#	src/auto_archiver/utils/gsheet.py
#	src/auto_archiver/utils/misc.py
This commit is contained in:
erinhmclark
2025-02-10 16:17:08 +00:00
12 changed files with 101 additions and 29 deletions

View File

@@ -3,6 +3,7 @@ import json
import uuid
from datetime import datetime, timezone
import requests
import hashlib
from loguru import logger
@@ -52,6 +53,7 @@ def update_nested_dict(dictionary, update_dict):
else:
dictionary[key] = value
def random_str(length: int = 32) -> str:
assert length <= 32, "length must be less than 32 as UUID4 is used"
return str(uuid.uuid4()).replace("-", "")[:length]
@@ -60,6 +62,15 @@ def random_str(length: int = 32) -> str:
def json_loader(cli_val):
return json.loads(cli_val)
def calculate_file_hash(filename: str, hash_algo = hashlib.sha256(), chunksize: int = 16000000) -> str:
with open(filename, "rb") as f:
while True:
buf = f.read(chunksize)
if not buf: break
hash_algo.update(buf)
return hash_algo.hexdigest()
def get_current_datetime_iso() -> str:
return datetime.now(timezone.utc).replace(tzinfo=timezone.utc).isoformat()