Merge branch 'SSL_fix'

This commit is contained in:
Marco
2019-07-29 15:33:18 +02:00
8 changed files with 4650 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
pandas>=0.24.2 pandas>=0.24.2
certifi>=2019.6.16 certifi>=2019.6.16
aiohttp>=3.5.4 aiohttp>=3.5.4
urllib3>=1.25.3 urllib3==1.24.3
pygame>=1.9.6 pygame>=1.9.6
QtAwesome>=0.5.7 QtAwesome>=0.5.7
PyQt5==5.12.2 PyQt5==5.12.2

View File

@@ -5,6 +5,7 @@ block_cipher = None
import glob, os import glob, os
data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"] data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"]
data_file.append(('cacert.pem', '.'))
a = Analysis(['artemis.py'], a = Analysis(['artemis.py'],
pathex=[os.getcwd()], pathex=[os.getcwd()],

View File

@@ -5,6 +5,7 @@ block_cipher = None
import glob,os import glob,os
data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"] data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"]
data_file.append(('cacert.pem', '.'))
a = Analysis(['artemis.py'], a = Analysis(['artemis.py'],
pathex=[os.getcwd()], pathex=[os.getcwd()],

View File

@@ -5,6 +5,7 @@ import glob, os
data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"] data_file = [(f, '.') for f in glob.glob('*.[pu][yi]') if f != "artemis.py"]
data_file.append(('themes','./themes')) data_file.append(('themes','./themes'))
data_file.append(('cacert.pem', '.'))
a = Analysis(['artemis.py'], a = Analysis(['artemis.py'],
pathex=[os.getcwd()], pathex=[os.getcwd()],

View File

@@ -43,7 +43,8 @@ from utilities import (checksum_ok,
is_undef_band, is_undef_band,
format_numbers, format_numbers,
resource_path, resource_path,
safe_cast) safe_cast,
is_mac_os)
# import default_imgs_rc # import default_imgs_rc
@@ -1627,7 +1628,7 @@ class Artemis(QMainWindow, Ui_MainWindow):
if __name__ == '__main__': if __name__ == '__main__':
# For executables running on Mac Os systems. # For executables running on Mac Os systems.
if hasattr(sys, "_MEIPASS") and sys.platform == 'darwin': if hasattr(sys, "_MEIPASS") and is_mac_os():
os.chdir(sys._MEIPASS) os.chdir(sys._MEIPASS)
my_app = QApplication(sys.argv) my_app = QApplication(sys.argv)

4619
src/cacert.pem Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,10 +7,9 @@ from shutil import rmtree
from time import perf_counter from time import perf_counter
from zipfile import ZipFile from zipfile import ZipFile
import aiohttp import aiohttp
import urllib3
from PyQt5.QtCore import QThread, pyqtSignal from PyQt5.QtCore import QThread, pyqtSignal
from constants import Constants, Database, ChecksumWhat from constants import Constants, Database, ChecksumWhat
from utilities import checksum_ok from utilities import checksum_ok, get_pool_manager
# Needed for pyinstaller compilation. # Needed for pyinstaller compilation.
import encodings.idna import encodings.idna
@@ -87,7 +86,7 @@ class DownloadThread(BaseDownloadThread):
raw_data = bytes(0) raw_data = bytes(0)
sub_data = bytes(0) sub_data = bytes(0)
try: try:
self._db = urllib3.PoolManager().request( self._db = get_pool_manager().request(
'GET', 'GET',
Database.LINK_LOC, Database.LINK_LOC,
preload_content=False, preload_content=False,

View File

@@ -2,10 +2,8 @@ from functools import partial
import hashlib import hashlib
import sys import sys
import os import os
from pandas import read_csv
from PyQt5.QtWidgets import QMessageBox from PyQt5.QtWidgets import QMessageBox
import urllib3
from constants import Constants, Signal, Database, ChecksumWhat from constants import Constants, Signal, Database, ChecksumWhat
@@ -51,6 +49,20 @@ def pop_up(cls, title, text,
return msg return msg
def is_mac_os():
"""Return True if running OS is Mac."""
return sys.platform == 'darwin'
def get_pool_manager():
"""Return a urllib3.PoolManager object."""
if hasattr(sys, "_MEIPASS"):
ca_certs = os.path.join(sys._MEIPASS, 'cacert.pem')
else:
ca_certs = 'cacert.pem'
return urllib3.PoolManager(ca_certs=ca_certs)
def checksum_ok(data, what): def checksum_ok(data, what):
"""Check whether the checksum of the 'data' argument is correct.""" """Check whether the checksum of the 'data' argument is correct."""
code = hashlib.sha256() code = hashlib.sha256()
@@ -62,10 +74,13 @@ def checksum_ok(data, what):
else: else:
raise ValueError("Wrong entry name.") raise ValueError("Wrong entry name.")
try: try:
reference = read_csv( # The downloaded file is a csv file with columns (last version == last line):
# data.zip_SHA256 | db.csv_SHA256 | Version | Creation_date
reference = get_pool_manager().request(
'GET',
Database.LINK_REF, Database.LINK_REF,
delimiter=Database.DELIMITER timeout=4.0
).iat[-1, n] ).data.decode("utf-8").splitlines()[-1].split(Database.DELIMITER)[n]
except Exception: except Exception:
raise raise
return code.hexdigest() == reference return code.hexdigest() == reference