Skip to content

Commit

Permalink
fix(install): fix installing to wrong directory
Browse files Browse the repository at this point in the history
If the initially proposed target path did not exist,
we ended up installing to this one instead of the one
selected by the user.

Also, removing unused exception class

Signed-off-by: Sylvain Leclerc <[email protected]>
  • Loading branch information
sylvlecl committed Oct 31, 2024
1 parent 183e36f commit 3c67de3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 31 deletions.
14 changes: 2 additions & 12 deletions src/antares_web_installer/gui/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,8 @@ def __init__(self, controller: Controller):
self.shortcut = True
self.launch = True

def set_target_dir(self, new_target_dir: Path) -> bool:
"""
Return False if target does not exist, True otherwise
@param new_target_dir:
@return:
"""
if not self.target_dir.exists():
logger.error("Target directory '{}' does not exist.".format(self.target_dir))
return False
else:
self.target_dir = new_target_dir
return True
def set_target_dir(self, new_target_dir: Path) -> None:
self.target_dir = new_target_dir

def set_shortcut(self, new_shortcut: bool):
self.shortcut = new_shortcut
Expand Down
4 changes: 0 additions & 4 deletions src/antares_web_installer/gui/mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ def show_error(self, *args):
messagebox.showerror("Exception", "".join(err))


class ControllerError(Exception):
pass


class Controller:
"""
Base class of the MVC controller.
Expand Down
10 changes: 2 additions & 8 deletions src/antares_web_installer/gui/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from tkinter import ttk, font
from tkinter.messagebox import showerror, showwarning

from antares_web_installer.gui.mvc import View, ControllerError, ViewError
from antares_web_installer.gui.mvc import View, ViewError
from antares_web_installer.gui.widgets.frame import (
WelcomeFrame,
PathChoicesFrame,
Expand Down Expand Up @@ -172,13 +172,7 @@ def set_launch(self, new_value: bool):
raise ViewError("Controller is not a WizardController")

def update_log_file(self):
try:
self.controller.update_log_file()
except ControllerError:
self.raise_error(
"The application was successfully installed although a minor error occurred. You may "
"continue or close the installer."
)
self.controller.update_log_file()

def run_installation(self, callback):
self.controller.install(callback)
Expand Down
9 changes: 2 additions & 7 deletions src/antares_web_installer/gui/widgets/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

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
Expand Down Expand Up @@ -153,12 +152,8 @@ def browse(self):
title="Choose the target directory",
initialdir=get_homedir(),
)
try:
self.window.set_target_dir(dir_path)
except ControllerError:
pass
else:
self.target_path.set(dir_path)
self.window.set_target_dir(dir_path)
self.target_path.set(dir_path)

def get_next_frame(self):
# Lazy import for typing and testing purposes
Expand Down

0 comments on commit 3c67de3

Please sign in to comment.