From df654066a80510bbca7cf5c5c007582f0d0836a2 Mon Sep 17 00:00:00 2001 From: neox95 Date: Wed, 10 Jul 2019 01:12:58 +0200 Subject: [PATCH] SHA1 added --- VERSIONS.LST | 2 +- src/updater.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/VERSIONS.LST b/VERSIONS.LST index 7f7d313..420bd0b 100644 --- a/VERSIONS.LST +++ b/VERSIONS.LST @@ -1,2 +1,2 @@ # ver|url|checksum, and | as separator, one version per || -3.0.0|https://neoxgroup.eu/ftpaccess/Applicatifs/CNIRevelator/CNIRevelator_2.2.5|1234||3.0.0|https://neoxgroup.eu/ftpaccess/Applicatifs/CNIRevelator/CNIRevelator_2.2.5|1234|| +3.0.1|https://github.com/neox95/CNIRevelator/releases/download/3.0.1-pre-alpha/CNIRevelator.zip|FIaHzUzgi7Lqmad7md9bzsvbdx4=|| diff --git a/src/updater.py b/src/updater.py index 36866b6..2172d59 100644 --- a/src/updater.py +++ b/src/updater.py @@ -31,6 +31,7 @@ import time import os import shutil import zipfile +import hashlib import logger # logger.py import globs # globs.py @@ -128,8 +129,23 @@ def batch(): logfile.printdbg('Preparing download for the new version') getTheUpdate = downloader.newdownload(credentials, finalurl, globs.CNIRFolder + '\\..\\CNIPackage.zip').download() + + # BUF_SIZE is totally arbitrary, change for your app! + BUF_SIZE = 65536 # lets read stuff in 64kb chunks! + + sha1 = hashlib.sha1() + + with open(globs.CNIRFolder + '\\..\\CNIPackage.zip', 'rb') as f: + while True: + data = f.read(BUF_SIZE) + if not data: + break + sha1.update(data) + + logfile.printdbg("SHA1: {0}".format(sha1.hexdigest())) # And now unzip and launch + logfile.printdbg("Unzipping the package") zip_ref = zipfile.ZipFile(globs.CNIRFolder + '\\..\\CNIPackage.zip', 'r') zip_ref.extractall(globs.CNIRFolder + '\\..\\CNIRevelator' + str(globs.verstring_full)) zip_ref.close()