diff --git a/fishy/gui/main_gui.py b/fishy/gui/main_gui.py index 6f9fdf1..207d463 100644 --- a/fishy/gui/main_gui.py +++ b/fishy/gui/main_gui.py @@ -61,12 +61,13 @@ def _create(gui: 'GUI'): def installer(): if filemenu.entrycget(4, 'label') == "Remove Chalutier": - helper.remove_addon(chalutier[0]) - filemenu.entryconfigure(4, label="Install Chalutier") + if helper.remove_addon(chalutier[0]) == 0: + filemenu.entryconfigure(4, label="Install Chalutier") else: - helper.install_addon(*chalutier) - helper.install_addon(*lam2) - filemenu.entryconfigure(4, label="Remove Chalutier") + r = helper.install_addon(*chalutier) + r += helper.install_addon(*lam2) + if r == 0: + filemenu.entryconfigure(4, label="Remove Chalutier") chaEntry = "Remove Chalutier" if helper.addon_exists(chalutier[0]) else "Install Chalutier" filemenu.add_command(label=chaEntry, command=installer) menubar.add_cascade(label="Options", menu=filemenu) diff --git a/fishy/helper/helper.py b/fishy/helper/helper.py index f73f154..c772edf 100644 --- a/fishy/helper/helper.py +++ b/fishy/helper/helper.py @@ -176,8 +176,10 @@ def install_addon(name, url, v=None): z = ZipFile(BytesIO(r.content)) z.extractall(path=get_addondir()) logging.info("Add-On "+name+" installed successfully!\nPlease make sure to enable \"Allow outdated addons\" in ESO") + return 0 except Exception as ex: logging.error("Could not install Add-On "+name+", try doing it manually") + return 1 def remove_addon(name, url=None, v=None): @@ -186,6 +188,10 @@ def remove_addon(name, url=None, v=None): logging.info("Add-On "+name+" removed!") except FileNotFoundError: pass + except PermissionError as ex: + logging.error("Fishy has no permission to remove "+name+" Add-On") + return 1 + return 0 def get_documents():