Add full cacert support for all platforms also for the checksum.
Distinguish compiled and script case. Adjust .spec files
This commit is contained in:
@@ -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()],
|
||||||
|
|||||||
@@ -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()],
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
@@ -4,13 +4,14 @@ from io import BytesIO
|
|||||||
from math import ceil
|
from math import ceil
|
||||||
import os.path
|
import os.path
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
import sys
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import urllib3
|
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 +88,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(ca_certs = sys._MEIPASS + '/cacert.pem').request(
|
self._db = get_pool_manager().request(
|
||||||
'GET',
|
'GET',
|
||||||
Database.LINK_LOC,
|
Database.LINK_LOC,
|
||||||
preload_content=False,
|
preload_content=False,
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ import hashlib
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from pandas import read_csv
|
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 +50,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')
|
||||||
|
return urllib3.PoolManager(ca_certs=ca_certs)
|
||||||
|
else:
|
||||||
|
return urllib3.PoolManager()
|
||||||
|
|
||||||
|
|
||||||
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 +75,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
|
||||||
|
|||||||
Reference in New Issue
Block a user