Fix bugs, add update system + tests + fix deployment/build system

This commit is contained in:
2022-09-12 00:29:39 +02:00
parent 981a11ce83
commit b46ecacbd9
8 changed files with 104 additions and 41 deletions

View File

@@ -1,5 +1,7 @@
import os
import webbrowser
from webpicdownloader.controller.Frames import Frames
from webpicdownloader.util.UpdateUtils import check_for_update
class MainController:
@@ -11,8 +13,8 @@ class MainController:
@author Jérémi Nihart / EndMove
@link https://git.endmove.eu/EndMove/WebPicDownloader
@version 1.0.0
@since 2022-08-30
@version 1.0.1
@since 2022-09-11
"""
# Variables
__config: dict = None
@@ -64,8 +66,13 @@ class MainController:
[event function for view]
=> Event launched when a check for available updates is requested.
"""
# TODO write the function
self.show_information_dialog(self.get_config('app_name'), "Oupss, this functionality isn't available yet!\nTry it again later.")
try:
if check_for_update(self.get_config('app_version'), self.get_config('app_depo_version'), self.get_config('sys_version_matcher')):
if self.show_question_dialog(self.get_config('app_name'), "An update is available! Would you like to visit the release page to download the latest version?"):
webbrowser.open(self.get_config('app_depo_releases'))
else: self.show_information_dialog(self.get_config('app_name'), "No update available.")
except Exception as e:
self.show_information_dialog(self.get_config('app_name'), f"An error occured: {e}.", 'error')
def on_about(self) -> None:
"""
@@ -85,12 +92,13 @@ class MainController:
"""
self.__view.show_frame(frame)
def get_config(self, name: str) -> str|int:
def get_config(self, name: str):
"""
[function for controller]
=> Allows controllers to access the application's configuration.
* :name: -> The name of the configuration parameter for which we want to access the configured value.
* THROWABLE -> If the key is wrong, throw a ValueError.
"""
if self.__config.get(name):
return self.__config.get(name)