mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[snap] showing a warning popup when the Snap API is out
This commit is contained in:
@@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
- Snap:
|
||||
- not waiting for the categories file to be retrieved from the cloud during application boot ( reduces boot time )
|
||||
- caching cloud categories to the disk so they can be used in scenarios when it is not possible to retrieve them ( e.g: internet is off )
|
||||
- showing a warning popup when the Snap API is out
|
||||
- minor thread improvements
|
||||
|
||||
### UI
|
||||
|
||||
@@ -188,6 +188,12 @@ class SnapManager(SoftwareManager):
|
||||
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']))]
|
||||
|
||||
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'))]
|
||||
|
||||
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))
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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.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
|
||||
snap.action.refresh.label=Refresh
|
||||
snap.install.available_channels.title=Available channels
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.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
|
||||
snap.action.refresh.label=Actualizar
|
||||
snap.install.available_channels.title=Canales disponibles
|
||||
|
||||
@@ -12,6 +12,7 @@ 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.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
|
||||
snap.action.refresh.label=Atualizar
|
||||
snap.install.available_channels.title=Canais disponíveis
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
from typing import List
|
||||
from io import StringIO
|
||||
from typing import List, Tuple
|
||||
|
||||
from bauh.commons.system import new_root_subprocess, run_cmd, new_subprocess, SimpleProcess
|
||||
from bauh.gems.snap.model import SnapApplication
|
||||
@@ -227,3 +228,14 @@ def run(app: SnapApplication, logger: logging.Logger):
|
||||
logger.error("No valid command found for '{}'".format(app_name))
|
||||
else:
|
||||
logger.error("No command found for '{}'".format(app_name))
|
||||
|
||||
|
||||
def is_api_available() -> Tuple[bool, str]:
|
||||
output = StringIO()
|
||||
for o in SimpleProcess(['snap', 'search']).instance.stdout:
|
||||
if o:
|
||||
output.write(o.decode())
|
||||
|
||||
output.seek(0)
|
||||
output = output.read()
|
||||
return 'error:' not in output, output
|
||||
|
||||
Reference in New Issue
Block a user