From 701331818865924e5ebf2c26781b29075f244e83 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Sat, 7 Jan 2023 00:15:42 +0100 Subject: [PATCH] Sostituito lancio programma con codice python. --- loaih/build.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/loaih/build.py b/loaih/build.py index 5649427..a99bc5b 100644 --- a/loaih/build.py +++ b/loaih/build.py @@ -10,6 +10,7 @@ import re import shlex import tempfile import urllib.request +import hashlib from lxml import etree import loaih @@ -387,13 +388,16 @@ class Build(loaih.RemoteBuild): def __create_checksum__(self, file): """Internal function to create checksum file.""" - checksum = subprocess.run( - f"md5sum {file}", shell=True, cwd=self.appnamedir, - capture_output=True, text=True, encoding='utf-8', check=True - ) - if checksum.stdout: - with open(f"{file}.md5", 'w', encoding='utf-8') as csfile: - csfile.write(checksum.stdout) + + checksum = hashlib.md5() + + with open(os.path.join(self.appnamedir, file), 'rb') as readfile: + for chunk in iter(lambda: readfile.read(4096), b""): + checksum.update(chunk) + + with open(f"{file}.md5", 'w', encoding='utf-8') as csfile: + csfile.write(checksum.hexdigest()) + def publish(self): """Moves built versions to definitive storage."""