From 1a8d37dfe6d5a7f6b73148363bde8c4f90c3b2b0 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 29 Oct 2019 11:19:25 -0300 Subject: [PATCH] [snap] The application crashes due to Snap API checking when snap is not installed | improved snapd not enabled warning --- CHANGELOG.md | 4 ++++ bauh/gems/snap/controller.py | 19 ++++++++++--------- bauh/gems/snap/resources/locale/en | 2 +- bauh/gems/snap/resources/locale/es | 2 +- bauh/gems/snap/resources/locale/pt | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 266c6266..39ead74c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.7.2] +### Fixes: + - The application crashes due to Snap API checking when snap is not installed + ## [0.7.1] 2019-10-25 ### Features - Snap: diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index 7ce13691..fb453a3f 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -197,17 +197,18 @@ class SnapManager(SoftwareManager): pass def list_warnings(self, internet_available: bool) -> List[str]: - if snap.is_installed() and not snap.is_snapd_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(self.i18n['manage_window.settings.gems']))] + if snap.is_installed(): + if not snap.is_snapd_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(self.i18n['manage_window.settings.gems']))] - if 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, pkg_name: str, priority: SuggestionPriority, out: List[PackageSuggestion]): res = self.http_client.get_json(SNAP_API_URL + '/search?q=package_name:{}'.format(pkg_name)) diff --git a/bauh/gems/snap/resources/locale/en b/bauh/gems/snap/resources/locale/en index cfe914b8..36f39134 100644 --- a/bauh/gems/snap/resources/locale/en +++ b/bauh/gems/snap/resources/locale/en @@ -1,5 +1,5 @@ gem.snap.info=Applications published at https://snapcraft.io/store -snap.notification.snapd_unavailable={} seems not to be installed or enabled. {} packages will not be available. +snap.notification.snapd_unavailable={} seems not to be started or enabled. {} packages will not be available. snap.notification.snap.disable=If you do not want to use Snap applications, uncheck {} in {} snap.notifications.api.unavailable=It seems the {} API is unavailable at the moment. It will not be possible to search for new {} applications. snap.action.refresh.status=Refreshing diff --git a/bauh/gems/snap/resources/locale/es b/bauh/gems/snap/resources/locale/es index 030edd69..4b17ee5a 100644 --- a/bauh/gems/snap/resources/locale/es +++ b/bauh/gems/snap/resources/locale/es @@ -10,7 +10,7 @@ snap.info.installed=instalado snap.info.publisher=publicador snap.info.version=versión snap.info.size=tamaño -snap.notification.snapd_unavailable={} no parece estar instalado o habilitado. Los paquetes {} estarán indisponibles. +snap.notification.snapd_unavailable={} parece no estar inicializado o habilitado. Los paquetes {} estarán indisponibles. snap.notification.snap.disable=Si no desea usar aplicativos Snap, desmarque {} en {} snap.notifications.api.unavailable=Parece que la API de {} no está disponible en este momento. No será posible buscar nuevos aplicativos {}. snap.action.refresh.status=Actualizando diff --git a/bauh/gems/snap/resources/locale/pt b/bauh/gems/snap/resources/locale/pt index d705e1f3..1d72fe63 100644 --- a/bauh/gems/snap/resources/locale/pt +++ b/bauh/gems/snap/resources/locale/pt @@ -10,7 +10,7 @@ snap.info.installed=instalado snap.info.publisher=publicador snap.info.version=versão snap.info.size=tamanho -snap.notification.snapd_unavailable={} não parece estar instalado ou habilitado. Os pacotes {} estarão indisponíveis. +snap.notification.snapd_unavailable={} parece não estar inicializado ou habilitado. Os pacotes {} estarão indisponíveis. snap.notification.snap.disable=Se não deseja usar aplicativos Snap, desmarque {} em {} snap.notifications.api.unavailable=Parece que a API de {} está indisponível no momento. Não será possível buscar novos aplicativos {}. snap.action.refresh.status=Atualizando