Skip to content
Snippets Groups Projects
Commit b3e3fda7 authored by yvesn's avatar yvesn
Browse files

obis - using python md5 hash function instead of calling external cmd for better compatibility

parent ee46da88
No related branches found
No related tags found
No related merge requests found
import hashlib
import json import json
import shutil import shutil
import os import os
...@@ -152,13 +153,18 @@ class ChecksumGeneratorCrc32(object): ...@@ -152,13 +153,18 @@ class ChecksumGeneratorCrc32(object):
class ChecksumGeneratorMd5(object): class ChecksumGeneratorMd5(object):
def get_checksum(self, file): def get_checksum(self, file):
md5_result = run_shell(['md5', file], raise_exception_on_failure=True)
return { return {
'checksum': md5_result.output.split(" ")[-1], 'checksum': self.md5(file),
'checksumType': 'MD5', 'checksumType': 'MD5',
'fileLength': os.path.getsize(file), 'fileLength': os.path.getsize(file),
'path': file 'path': file
} }
def md5(self, file):
hash_md5 = hashlib.md5()
with open(file, "rb") as f:
for chunk in iter(lambda: f.read(4096), b""):
hash_md5.update(chunk)
return hash_md5.hexdigest()
class ChecksumGeneratorGitAnnex(object): class ChecksumGeneratorGitAnnex(object):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment