From 1962e4481cc9b2802d4ff121381c213431d7782a Mon Sep 17 00:00:00 2001 From: Maurane GLAUDE Date: Tue, 10 Sep 2024 11:42:08 +0200 Subject: [PATCH] fix(gui.windows): reformat code with ruff --- src/antares_web_installer/app.py | 4 ++-- src/antares_web_installer/gui/controller.py | 6 +++--- src/antares_web_installer/gui/widgets/frame.py | 9 +++++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/antares_web_installer/app.py b/src/antares_web_installer/app.py index 9d74488..1e13bac 100644 --- a/src/antares_web_installer/app.py +++ b/src/antares_web_installer/app.py @@ -222,7 +222,7 @@ def create_shortcuts(self): desktop_path = Path(get_desktop()) logger.info("Generating server shortcut on desktop...") - name, ext = SHORTCUT_NAMES[os.name].split('.') + name, ext = SHORTCUT_NAMES[os.name].split(".") new_shortcut_name = f"{name}-{self.version}.{ext}" shortcut_path = desktop_path.joinpath(new_shortcut_name) @@ -294,7 +294,7 @@ def start_server(self): if nb_attempts == max_attempts: try: httpx.get("http://localhost:8080/", timeout=1) - except httpx.ConnectTimeout: + except httpx.ConnectTimeout as e: logger.error("Impossible to launch Antares Web Server after {nb_attempts} attempts.") raise InstallError(f"Impossible to launch Antares Web Server after {nb_attempts} attempts: {e}") time.sleep(5) diff --git a/src/antares_web_installer/gui/controller.py b/src/antares_web_installer/gui/controller.py index 218bcc7..8afd4a7 100644 --- a/src/antares_web_installer/gui/controller.py +++ b/src/antares_web_installer/gui/controller.py @@ -91,7 +91,7 @@ def init_log_file_handler(self): # initialize file handler logger def init_console_handler(self, callback): """ - + @param callback: @return: """ @@ -117,8 +117,8 @@ def run(self) -> None: def install(self, callback: typing.Callable): """ - Run App.install method - @param callback: function that is used to update logs + Run App.install method + @param callback: function that is used to update logs """ self.init_log_file_handler() self.logger.debug("file logger initialized.") diff --git a/src/antares_web_installer/gui/widgets/frame.py b/src/antares_web_installer/gui/widgets/frame.py index e53e239..e7234e9 100644 --- a/src/antares_web_installer/gui/widgets/frame.py +++ b/src/antares_web_installer/gui/widgets/frame.py @@ -5,6 +5,7 @@ from antares_web_installer.shortcuts import get_homedir from .button import CancelBtn, BackBtn, NextBtn, FinishBtn, InstallBtn +from ..mvc import ControllerError if TYPE_CHECKING: from antares_web_installer.gui.view import WizardView @@ -152,8 +153,12 @@ def browse(self): title="Choose the target directory", initialdir=get_homedir(), ) - self.window.set_target_dir(dir_path) - self.target_path.set(dir_path) + try: + self.window.set_target_dir(dir_path) + except ControllerError: + pass + else: + self.target_path.set(dir_path) def get_next_frame(self): # Lazy import for typing and testing purposes