From 14008e4ad540420f6f0465dc4489be36cf50cce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Wed, 18 Dec 2019 19:41:22 -0300 Subject: [PATCH] [web] displaying the config dir on the info window | removing the config dir during uninstallation --- bauh/gems/web/controller.py | 30 +++++++++++++++++++++++------- bauh/gems/web/model.py | 13 +++++++++++++ bauh/gems/web/resources/locale/en | 19 ++++++++++--------- bauh/gems/web/resources/locale/es | 19 ++++++++++--------- bauh/gems/web/resources/locale/pt | 19 ++++++++++--------- 5 files changed, 66 insertions(+), 34 deletions(-) diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index dc278f39..84ffb53e 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -308,7 +308,18 @@ class WebApplicationManager(SoftwareManager): except: watcher.show_message(title=self.i18n['error'], body=self.i18n['web.uninstall.error.remove'].format(bold(autostart_path)), - type_=MessageType.ERROR) + type_=MessageType.WARNING) + traceback.print_exc() + + config_path = pkg.get_config_dir() + + if os.path.exists(config_path): + try: + shutil.rmtree(config_path) + except: + watcher.show_message(title=self.i18n['error'], + body=self.i18n['web.uninstall.error.remove'].format(bold(config_path)), + type_=MessageType.WARNING) traceback.print_exc() return True @@ -318,15 +329,20 @@ class WebApplicationManager(SoftwareManager): def get_info(self, pkg: WebApplication) -> dict: if pkg.installed: - info = {'{}_{}'.format(idx + 1, att): getattr(pkg, att) for idx, att in enumerate(('url', 'description', 'version', 'categories', 'installation_dir', 'desktop_entry'))} - info['7_exec_file'] = pkg.get_exec_path() - info['8_icon_path'] = pkg.get_disk_icon_path() + info = {'0{}_{}'.format(idx + 1, att): getattr(pkg, att) for idx, att in enumerate(('url', 'description', 'version', 'categories', 'installation_dir', 'desktop_entry'))} + info['07_exec_file'] = pkg.get_exec_path() + info['08_icon_path'] = pkg.get_disk_icon_path() if os.path.exists(pkg.installation_dir): - info['9_size'] = get_human_size_str(get_dir_size(pkg.installation_dir)) + info['09_size'] = get_human_size_str(get_dir_size(pkg.installation_dir)) - if info.get('4_categories'): - info['4_categories'] = [self.i18n[c.lower()].capitalize() for c in info['4_categories']] + config_dir = pkg.get_config_dir() + + if config_dir: + info['10_config_dir'] = config_dir + + if info.get('04_categories'): + info['04_categories'] = [self.i18n[c.lower()].capitalize() for c in info['04_categories']] return info diff --git a/bauh/gems/web/model.py b/bauh/gems/web/model.py index 3d2933c6..d756d610 100644 --- a/bauh/gems/web/model.py +++ b/bauh/gems/web/model.py @@ -1,3 +1,5 @@ +import glob +import os from pathlib import Path from typing import List @@ -113,3 +115,14 @@ class WebApplication(SoftwarePackage): if custom_icon: self.icon_url = custom_icon + def get_config_dir(self) -> str: + if self.installation_dir: + config_path = '{}/.config'.format(Path.home()) + + if os.path.exists(config_path): + config_dirs = glob.glob('{}/{}-nativefier-*'.format(config_path, self.installation_dir.split('/')[-1])) + + if config_dirs: + return config_dirs[0] + + diff --git a/bauh/gems/web/resources/locale/en b/bauh/gems/web/resources/locale/en index eddb8f81..d34ef120 100644 --- a/bauh/gems/web/resources/locale/en +++ b/bauh/gems/web/resources/locale/en @@ -44,12 +44,13 @@ web.install.option.icon.label=Custom icon web.install.global_nativefier.unavailable={n} seems not to be installed on your system. It will not be possible to install {app} web.uninstall.error.install_dir.not_found=The installation directory {} was not found web.uninstall.error.remove_dir=It was not possible to remove {} -web.info.1_url=URL -web.info.2_description=description -web.info.3_version=version -web.info.4_categories=categories -web.info.5_installation_dir=installation dir -web.info.6_desktop_entry=shortcut -web.info.7_exec_file=executable -web.info.8_icon_path=icon -web.info.9_size=size \ No newline at end of file +web.info.01_url=URL +web.info.02_description=description +web.info.03_version=version +web.info.04_categories=categories +web.info.05_installation_dir=installation dir +web.info.06_desktop_entry=shortcut +web.info.07_exec_file=executable +web.info.08_icon_path=icon +web.info.09_size=size +web.info.10_config_dir=configuration dir \ No newline at end of file diff --git a/bauh/gems/web/resources/locale/es b/bauh/gems/web/resources/locale/es index e75fffb2..7e2aca60 100644 --- a/bauh/gems/web/resources/locale/es +++ b/bauh/gems/web/resources/locale/es @@ -44,12 +44,13 @@ web.install.option.icon.label=Icono personalizado web.install.global_nativefier.unavailable={n} parece no estar instalado en su sistema. No será posible instalar {app} web.uninstall.error.install_dir.not_found=No se encontró el directorio de instalación {} web.uninstall.error.remove_dir=No fue posible eliminar {} -web.info.1_url=URL -web.info.2_description=descripción -web.info.3_version=versión -web.info.4_categories=categorías -web.info.5_installation_dir=directorio de instalación -web.info.6_desktop_entry=atajo -web.info.7_exec_file=ejecutable -web.info.8_icon_path=icono -web.info.9_size=tamaño \ No newline at end of file +web.info.01_url=URL +web.info.02_description=descripción +web.info.03_version=versión +web.info.04_categories=categorías +web.info.05_installation_dir=directorio de instalación +web.info.06_desktop_entry=atajo +web.info.07_exec_file=ejecutable +web.info.08_icon_path=icono +web.info.09_size=tamaño +web.info.10_config_dir=directorio de configuración \ No newline at end of file diff --git a/bauh/gems/web/resources/locale/pt b/bauh/gems/web/resources/locale/pt index 6a287a5d..f7030368 100644 --- a/bauh/gems/web/resources/locale/pt +++ b/bauh/gems/web/resources/locale/pt @@ -44,12 +44,13 @@ web.install.option.icon.label=Ícone alternativo web.install.global_nativefier.unavailable={n} não parece estar instalado no seu sistema. Não será possível instalar {app} web.uninstall.error.install_dir.not_found=O diretório de instalação {} não foi encontrado web.uninstall.error.remove=Não foi possível remover {} -web.info.1_url=URL -web.info.2_description=descrição -web.info.3_version=versão -web.info.4_categories=categorias -web.info.5_installation_dir=diretório de instalação -web.info.6_desktop_entry=atalho -web.info.7_exec_file=executável -web.info.8_icon_path=ícone -web.info.9_size=tamanho \ No newline at end of file +web.info.01_url=URL +web.info.02_description=descrição +web.info.03_version=versão +web.info.04_categories=categorias +web.info.05_installation_dir=diretório de instalação +web.info.06_desktop_entry=atalho +web.info.07_exec_file=executável +web.info.08_icon_path=ícone +web.info.09_size=tamanho +web.info.10_config_dir=diretório de configuração \ No newline at end of file