Reimplemented md5sum with python functions.
This commit is contained in:
parent
62248d862c
commit
49e0ab5593
|
@ -10,6 +10,7 @@ import re
|
||||||
import shlex
|
import shlex
|
||||||
import tempfile
|
import tempfile
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import hashlib
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
import loaih
|
import loaih
|
||||||
|
|
||||||
|
@ -424,13 +425,22 @@ class Build(loaih.RemoteBuild):
|
||||||
def __create_checksum__(self, file):
|
def __create_checksum__(self, file):
|
||||||
"""Internal function to create checksum 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,
|
checksum = subprocess.run(f"md5sum {file}", shell=True,
|
||||||
capture_output=True, text=True, encoding='utf-8', check=True,
|
capture_output=True, text=True, encoding='utf-8', check=True,
|
||||||
cwd=self.appnamedir)
|
cwd=self.appnamedir)
|
||||||
|
|
||||||
if checksum.stdout:
|
if checksum.stdout:
|
||||||
with open(f"{file}.md5", 'w', encoding='utf-8') as checkfile:
|
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):
|
def publish(self):
|
||||||
|
|
Loading…
Reference in New Issue