Update to master, updated requirements and certificates
This commit is contained in:
@@ -52,6 +52,8 @@ class Messages:
|
|||||||
NO_CONNECTION_MSG = "Unable to establish an internet connection."
|
NO_CONNECTION_MSG = "Unable to establish an internet connection."
|
||||||
BAD_DOWNLOAD = "Something went wrong"
|
BAD_DOWNLOAD = "Something went wrong"
|
||||||
BAD_DOWNLOAD_MSG = "Something went wrong with the downaload.\nCheck your internet connection and try again."
|
BAD_DOWNLOAD_MSG = "Something went wrong with the downaload.\nCheck your internet connection and try again."
|
||||||
|
SLOW_CONN = "Slow internet connection"
|
||||||
|
SLOW_CONN_MSG = "Your internet connection is unstable or too slow."
|
||||||
|
|
||||||
|
|
||||||
class Signal:
|
class Signal:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
pandas==0.24.2
|
pandas>=0.24.2
|
||||||
aiohttp==3.5.4
|
certifi>=2019.6.16
|
||||||
pygame==1.9.6
|
aiohttp>=3.5.4
|
||||||
QtAwesome==0.5.7
|
pygame>=1.9.6
|
||||||
urllib3==1.24.2
|
QtAwesome>=0.5.7
|
||||||
PyQt5==5.12.2
|
urllib3>=1.25.3
|
||||||
|
PyQt5>=5.12.3
|
||||||
|
|||||||
@@ -1,36 +1,7 @@
|
|||||||
aiohttp==3.5.4
|
pandas>=0.24.2
|
||||||
altgraph==0.16.1
|
certifi>=2019.6.16
|
||||||
asn1crypto==0.24.0
|
aiohttp>=3.5.4
|
||||||
async-timeout==3.0.1
|
pygame>=1.9.6
|
||||||
attrs==19.1.0
|
QtAwesome>=0.5.7
|
||||||
certifi==2019.3.9
|
urllib3>=1.25.3
|
||||||
cffi==1.11.5
|
PyQt5>=5.12.3
|
||||||
chardet==3.0.4
|
|
||||||
cryptography==2.3.1
|
|
||||||
Cython==0.29.6
|
|
||||||
future==0.16.0
|
|
||||||
idna==2.7
|
|
||||||
intel-openmp==2019.0
|
|
||||||
macholib==1.11
|
|
||||||
multidict==4.5.2
|
|
||||||
numpy==1.15.2
|
|
||||||
pandas==0.23.4
|
|
||||||
pefile==2018.8.8
|
|
||||||
pycparser==2.19
|
|
||||||
pydub==0.23.0
|
|
||||||
pygame==1.9.4
|
|
||||||
PyInstaller==3.4
|
|
||||||
pyOpenSSL==18.0.0
|
|
||||||
PyQt5==5.10.1
|
|
||||||
PySocks==1.6.8
|
|
||||||
python-dateutil==2.7.3
|
|
||||||
pytz==2018.5
|
|
||||||
pywin32-ctypes==0.2.0
|
|
||||||
QtAwesome==0.5.0
|
|
||||||
QtPy==1.5.1
|
|
||||||
sip==4.19.8
|
|
||||||
six==1.11.0
|
|
||||||
urllib3==1.24
|
|
||||||
win-inet-pton==1.0.1
|
|
||||||
wincertstore==0.2
|
|
||||||
yarl==1.3.0
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
|||||||
text=Messages.BAD_DOWNLOAD_MSG,
|
text=Messages.BAD_DOWNLOAD_MSG,
|
||||||
connection=self.close)
|
connection=self.close)
|
||||||
|
|
||||||
|
self._slow_conn_msg = pop_up(self, title=Messages.SLOW_CONN,
|
||||||
|
text=Messages.SLOW_CONN_MSG,
|
||||||
|
connection=self.close)
|
||||||
|
|
||||||
self._download_thread = DownloadThread()
|
self._download_thread = DownloadThread()
|
||||||
self._download_thread.finished.connect(self._wait_close)
|
self._download_thread.finished.connect(self._wait_close)
|
||||||
self._download_thread.progress.connect(self._display_progress)
|
self._download_thread.progress.connect(self._display_progress)
|
||||||
@@ -49,7 +53,12 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
|||||||
|
|
||||||
def _downlaod_format_str(self, n, speed):
|
def _downlaod_format_str(self, n, speed):
|
||||||
"""Return a well-formatted string with downloaded MB and speed."""
|
"""Return a well-formatted string with downloaded MB and speed."""
|
||||||
return f"Downloaded: {n} MB\nSpeed: {speed} MB/s"
|
ret = f"Downloaded: {n} MB\nSpeed: "
|
||||||
|
if speed == 0.0:
|
||||||
|
ret += "VERY SLOW"
|
||||||
|
else:
|
||||||
|
ret += f"{speed} MB/s"
|
||||||
|
return ret
|
||||||
|
|
||||||
def show(self):
|
def show(self):
|
||||||
"""Extends QWidget.show. Set downloaded MB and speed to zero."""
|
"""Extends QWidget.show. Set downloaded MB and speed to zero."""
|
||||||
@@ -86,6 +95,8 @@ class DownloadWindow(QWidget, Ui_Download_window):
|
|||||||
self._no_internet_msg.show()
|
self._no_internet_msg.show()
|
||||||
elif self._download_thread.status is ThreadStatus.BAD_DOWNLOAD_ERR:
|
elif self._download_thread.status is ThreadStatus.BAD_DOWNLOAD_ERR:
|
||||||
self._bad_db_download_msg.show()
|
self._bad_db_download_msg.show()
|
||||||
|
elif self._download_thread.status is ThreadStatus.SLOW_CONN_ERR:
|
||||||
|
self._slow_conn_msg.show()
|
||||||
else:
|
else:
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|||||||
24
threads.py
24
threads.py
@@ -4,7 +4,7 @@ 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
|
||||||
from time import time
|
from time import perf_counter
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import urllib3
|
import urllib3
|
||||||
@@ -21,6 +21,11 @@ class ThreadStatus(Enum):
|
|||||||
UNKNOWN_ERR = auto()
|
UNKNOWN_ERR = auto()
|
||||||
BAD_DOWNLOAD_ERR = auto()
|
BAD_DOWNLOAD_ERR = auto()
|
||||||
UNDEFINED = auto()
|
UNDEFINED = auto()
|
||||||
|
SLOW_CONN_ERR = auto()
|
||||||
|
|
||||||
|
|
||||||
|
class _SlowConnError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BaseDownloadThread(QThread):
|
class BaseDownloadThread(QThread):
|
||||||
@@ -41,7 +46,7 @@ class DownloadThread(BaseDownloadThread):
|
|||||||
"""Subclass BaseDownloadThread. Download the database, images and audio samples."""
|
"""Subclass BaseDownloadThread. Download the database, images and audio samples."""
|
||||||
|
|
||||||
progress = pyqtSignal(int, float)
|
progress = pyqtSignal(int, float)
|
||||||
_CHUNK = 512 * 1024
|
_CHUNK = 128 * 1024
|
||||||
_MEGA = 1024**2
|
_MEGA = 1024**2
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -82,27 +87,30 @@ class DownloadThread(BaseDownloadThread):
|
|||||||
preload_content=False,
|
preload_content=False,
|
||||||
timeout=4.0
|
timeout=4.0
|
||||||
)
|
)
|
||||||
|
start = perf_counter()
|
||||||
while True:
|
while True:
|
||||||
start = time()
|
|
||||||
try:
|
try:
|
||||||
data = self._db.read(self._CHUNK)
|
data = self._db.read(self._CHUNK)
|
||||||
except Exception:
|
except Exception:
|
||||||
raise
|
raise _SlowConnError
|
||||||
else:
|
else:
|
||||||
delta = time() - start
|
delta = perf_counter() - start
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
raw_data += data
|
raw_data += data
|
||||||
self.progress.emit(
|
self.progress.emit(
|
||||||
self._pretty_len(raw_data),
|
self._pretty_len(raw_data),
|
||||||
self._get_download_speed(data, delta)
|
self._get_download_speed(raw_data, delta)
|
||||||
)
|
)
|
||||||
if self._exit_call:
|
if self._exit_call:
|
||||||
self._exit_call = False
|
self._exit_call = False
|
||||||
self._db.release_conn()
|
self._db.release_conn()
|
||||||
return
|
return
|
||||||
except Exception: # No internet connection.
|
except Exception as e: # No (or bad) internet connection.
|
||||||
self._db.release_conn()
|
self._db.release_conn()
|
||||||
|
if isinstance(e, _SlowConnError):
|
||||||
|
self.status = ThreadStatus.SLOW_CONN_ERR
|
||||||
|
else:
|
||||||
self.status = ThreadStatus.NO_CONNECTION_ERR
|
self.status = ThreadStatus.NO_CONNECTION_ERR
|
||||||
return
|
return
|
||||||
if self._db.status != 200:
|
if self._db.status != 200:
|
||||||
@@ -110,7 +118,7 @@ class DownloadThread(BaseDownloadThread):
|
|||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
is_checksum_ok = checksum_ok(raw_data, ChecksumWhat.FOLDER)
|
is_checksum_ok = checksum_ok(raw_data, ChecksumWhat.FOLDER)
|
||||||
except Exception:
|
except Exception: # checksum_ok unable to connect to the reference.
|
||||||
self.status = ThreadStatus.NO_CONNECTION_ERR
|
self.status = ThreadStatus.NO_CONNECTION_ERR
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user