From 0a9133068e6cfa20fcbec8dd76e5f27f9a420dae Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 12:47:13 -0300 Subject: [PATCH] [view] fix: displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies --- CHANGELOG.md | 3 ++- bauh/api/abstract/controller.py | 2 +- bauh/gems/arch/controller.py | 17 +++-------------- bauh/gems/flatpak/controller.py | 4 ++-- bauh/gems/snap/controller.py | 25 ++++++++++++------------- bauh/gems/web/controller.py | 2 +- bauh/view/core/controller.py | 2 +- 7 files changed, 22 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1777bc..e3af2611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - not displaying the updates size for Flatpak 1.2 - UI - - upgrade summary: not displaying the icon type for some applications + - upgrade summary: not displaying the icon type for some applications + - displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies ## [0.9.20] 2021-11-05 ### Improvements diff --git a/bauh/api/abstract/controller.py b/bauh/api/abstract/controller.py index 4fbe1635..7c009539 100644 --- a/bauh/api/abstract/controller.py +++ b/bauh/api/abstract/controller.py @@ -318,7 +318,7 @@ class SoftwareManager(ABC): pass @abstractmethod - def list_warnings(self, internet_available: bool) -> List[str]: + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: """ :param internet_available :return: a list of warnings to be shown to the user diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index c9bdf3ce..509a9066 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2733,20 +2733,9 @@ class ArchManager(SoftwareManager): return [PackageUpdate(p.name, p.latest_version, aur_type if p.repository == 'aur' else repo_type, p.name) for p in installed if p.update and not p.is_update_ignored()] - def list_warnings(self, internet_available: bool) -> List[str]: - warnings = [] - - if self.arch_distro: - if not pacman.is_available(): - warnings.append(self.i18n['arch.warning.disabled'].format(bold('pacman'))) - - if not self._is_wget_available(): - warnings.append(self.i18n['arch.warning.disabled'].format(bold('wget'))) - - if not git.is_installed(): - warnings.append(self.i18n['arch.warning.git'].format(bold('git'))) - - return warnings + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + if not git.is_installed(): + return [self.i18n['arch.warning.git'].format(bold('git'))] def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]: self.logger.info("Downloading suggestions file {}".format(SUGGESTIONS_FILE)) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 360f4395..b57d95af 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -517,8 +517,8 @@ class FlatpakManager(SoftwareManager): return updates - def list_warnings(self, internet_available: bool) -> List[str]: - return [] + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + pass def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]: cli_version = flatpak.get_version() diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index db8dcb53..fc8c7b67 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -317,20 +317,19 @@ class SnapManager(SoftwareManager): def list_updates(self, internet_available: bool) -> List[PackageUpdate]: pass - def list_warnings(self, internet_available: bool) -> List[str]: - if snap.is_installed(): - if not snapd.is_running(): - snap_bold = bold('Snap') - return [self.i18n['snap.notification.snapd_unavailable'].format(bold('snapd'), snap_bold), - self.i18n['snap.notification.snap.disable'].format(snap_bold, bold('{} > {}'.format(self.i18n['settings'].capitalize(), - self.i18n['core.config.tab.types'])))] + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + if not snapd.is_running(): + snap_bold = bold('Snap') + return [self.i18n['snap.notification.snapd_unavailable'].format(bold('snapd'), snap_bold), + self.i18n['snap.notification.snap.disable'].format(snap_bold, bold( + '{} > {}'.format(self.i18n['settings'].capitalize(), + self.i18n['core.config.tab.types'])))] + elif internet_available: + available, output = snap.is_api_available() - elif internet_available: - available, output = snap.is_api_available() - - if not available: - self.logger.warning('It seems Snap API is not available. Search output: {}'.format(output)) - return [self.i18n['snap.notifications.api.unavailable'].format(bold('Snaps'), bold('Snap'))] + if not available: + self.logger.warning('It seems Snap API is not available. Search output: {}'.format(output)) + return [self.i18n['snap.notifications.api.unavailable'].format(bold('Snaps'), bold('Snap'))] def _fill_suggestion(self, name: str, priority: SuggestionPriority, snapd_client: SnapdClient, out: List[PackageSuggestion]): res = snapd_client.find_by_name(name) diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index 66fd8cb1..8d67ec72 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -848,7 +848,7 @@ class WebApplicationManager(SoftwareManager): def list_updates(self, internet_available: bool) -> List[PackageUpdate]: pass - def list_warnings(self, internet_available: bool) -> List[str]: + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: pass def _fill_suggestion(self, app: WebApplication): diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index ac0e2159..6e4ccdcd 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -461,7 +461,7 @@ class GenericSoftwareManager(SoftwareManager): if self.managers: for man in self.managers: - if man.is_enabled(): + if self._can_work(man): man_warnings = man.list_warnings(internet_available=int_available) if man_warnings: