Final ieration of the new downloader and update_manager, implemented automatic updates only for windows

This commit is contained in:
Marco Dalla Tiezza
2024-06-13 15:46:25 +02:00
parent 146a5d1605
commit 77c43813a0
5 changed files with 285 additions and 231 deletions

View File

@@ -6,10 +6,10 @@ from PySide6.QtCore import QObject, Slot, Signal
from artemis.utils.constants import Constants, Messages
from artemis.utils.sys_utils import open_directory, make_tar, unpack_tar
from artemis.utils.sql_utils import ArtemisDatabase, ArtemisSignal
from artemis.utils.path_utils import DATA_DIR
from artemis.utils.update_utils import UpdateManager
from artemis.utils.generic_utils import generate_filter_query
from artemis.utils.path_utils import normalize_dialog_path
from artemis.utils.path_utils import DATA_DIR
from artemis.utils.config_utils import CONFIGURE_QT
from artemis.ui.preferences import UIPreferences
@@ -25,6 +25,7 @@ import artemis.resources
class UIArtemis(QObject):
# Python > QML Signals
close_ui = Signal()
populate_sig_list = Signal(list)
populate_sig_details = Signal(list)
populate_filter_modulation = Signal(list)
@@ -79,8 +80,8 @@ class UIArtemis(QObject):
self._window.loadSignal.connect(self.load_sig)
self._window.showPref.connect(self.show_pref_ui)
self._window.openSigEditor.connect(self.open_sig_editor)
self._window.startDownloader.connect(self.start_download_db)
self._window.checkDbUpdates.connect(self.check_update_db)
self._window.checkForUpdate.connect(self.check_for_update)
self._window.updateDb.connect(self.update_db)
self._window.updateArtemis.connect(self.update_artemis)
self._window.showSpaceWeather.connect(self.show_space_weather_ui)
self._window.openDbDirectory.connect(self.open_db_directory)
@@ -99,6 +100,7 @@ class UIArtemis(QObject):
self._window_signal.addCatTag.connect(self.add_cat_tag)
# Python > QML connections
self.close_ui.connect(self._window.close)
self.populate_sig_list.connect(self._window.populateList)
self.clear_list.connect(self._window.clearList)
self.update_info_bar.connect(self._window.bottomInfoBar)
@@ -215,22 +217,12 @@ class UIArtemis(QObject):
self.docmanager.load_documentsmanager_ui()
def check_update_db(self):
""" User manual check for updates db updates
def check_for_update(self):
""" User manual check for updates updates
"""
self.update_manager.check_updates(True)
def start_download_db(self):
""" Show the downloader and start the download of the sigid db
"""
self.downloader.finished.connect(self.update_manager.post_download_db)
self.downloader.on_start(
self.update_manager.remote_db_url,
DATA_DIR
)
def dialog_download_db(self, message_type, title, message):
""" Dialog popup for DB download confirmation
"""
@@ -238,14 +230,23 @@ class UIArtemis(QObject):
def dialog_update_artemis(self, message_type, title, message, auto=False):
""" Dialog popup for artemis download confirmation
""" Dialog popup for Artemis download confirmation
"""
self.show_dialog_update_artemis.emit(message_type, title, message, auto)
@Slot()
def update_db(self):
""" Start the download of the sigID DB
"""
self.update_manager.download_db()
@Slot()
def update_artemis(self):
print('ciao')
""" Start the download of Artemis
"""
self.update_manager.download_artemis()
def open_db_directory(self):

View File

@@ -55,7 +55,7 @@ class UIDownloader(QObject):
url (str): url from where download the file
save_path (str): path where to save the downloaded file
"""
self._clear_ui()
self.show_ui.emit()
self.file_url = QUrl(url)
@@ -85,8 +85,6 @@ class UIDownloader(QObject):
"""
if self.reply:
self.reply.abort()
self.update_progress_bar.emit(0, 0)
self.update_status.emit('')
if self.file:
self.file.cancelWriting()
@@ -103,8 +101,8 @@ class UIDownloader(QObject):
@Slot()
def on_finished(self):
""" Finalize the download process and if no errors
occurs emits the finished signal usefulle for
""" Finalize the download process and, if no errors
occurs, emits the finished signal usefull for
a callback
"""
if self.reply:
@@ -144,6 +142,7 @@ class UIDownloader(QObject):
def _get_filesize(self, url):
""" Get the file size by sending a HEAD request to the URL.
If the Content-Length in HTTP headers is missing, returns None
and set the progress_bar as 'indeterminate' like a 'busy indicator'
Args:
url (str): URL to check the file size
@@ -157,6 +156,11 @@ class UIDownloader(QObject):
return None
def _clear_ui(self):
self.update_progress_bar.emit(0, 0)
self.update_status.emit('')
def show_popup_error(self, error_msg):
self._parent.dialog_popup(
Messages.DIALOG_TYPE_ERROR,