Add checksum control od db download and switch to urllib3

This commit is contained in:
alessandro90
2018-11-03 20:38:05 +01:00
parent e28d3b6286
commit f224fcc0bc
3 changed files with 46 additions and 8 deletions

18
utilities.py Normal file
View File

@@ -0,0 +1,18 @@
import hashlib
from pandas import read_csv
def checksum_ok(data, what):
code = hashlib.sha256()
code.update(data)
ref_loc = 'https://aresvalley.com/Storage/Artemis/Database/data.zip.log'
if what == "folder":
n = 0
elif what == "db":
n = 1
else:
raise ValueError("Wrong entry name.")
try:
reference = read_csv(ref_loc, delimiter = '*').iat[-1, n]
except HTTPError:
return False
return code.hexdigest() == reference