Reimplemented md5sum with python functions.
This commit is contained in:
parent
62248d862c
commit
49e0ab5593
|
@ -10,6 +10,7 @@ import re
|
|||
import shlex
|
||||
import tempfile
|
||||
import urllib.request
|
||||
import hashlib
|
||||
from lxml import etree
|
||||
import loaih
|
||||
|
||||
|
@ -424,13 +425,22 @@ class Build(loaih.RemoteBuild):
|
|||
def __create_checksum__(self, file):
|
||||
"""Internal function to create checksum file."""
|
||||
|
||||
retval = hashlib.md5()
|
||||
with open(file, 'rb') as rawfile:
|
||||
while True:
|
||||
buf = rawfile.read(2**20)
|
||||
if not buf:
|
||||
break
|
||||
|
||||
retval.update(buf)
|
||||
|
||||
checksum = subprocess.run(f"md5sum {file}", shell=True,
|
||||
capture_output=True, text=True, encoding='utf-8', check=True,
|
||||
cwd=self.appnamedir)
|
||||
|
||||
if checksum.stdout:
|
||||
with open(f"{file}.md5", 'w', encoding='utf-8') as checkfile:
|
||||
checkfile.write(checksum.stdout)
|
||||
checkfile.write(f"{retval.hexdigest()} {os.path.basename(file)}")
|
||||
|
||||
|
||||
def publish(self):
|
||||
|
|
Loading…
Reference in New Issue