mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[snap] fix: not showing 'API is out' popup when there is no internet connection
This commit is contained in:
@@ -213,8 +213,9 @@ class SoftwareManager(ABC):
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def list_warnings(self) -> List[str]:
|
||||
def list_warnings(self, internet_available: bool) -> List[str]:
|
||||
"""
|
||||
:param internet_available
|
||||
:return: a list of warnings to be shown to the user
|
||||
"""
|
||||
pass
|
||||
|
||||
@@ -396,7 +396,7 @@ class AppImageManager(SoftwareManager):
|
||||
|
||||
return updates
|
||||
|
||||
def list_warnings(self) -> List[str]:
|
||||
def list_warnings(self, internet_available: bool) -> List[str]:
|
||||
pass
|
||||
|
||||
def list_suggestions(self, limit: int) -> List[PackageSuggestion]:
|
||||
|
||||
@@ -710,7 +710,7 @@ class ArchManager(SoftwareManager):
|
||||
installed = self.read_installed(disk_loader=None, internet_available=internet_available).installed
|
||||
return [PackageUpdate(p.id, p.latest_version, 'aur') for p in installed if p.update]
|
||||
|
||||
def list_warnings(self) -> List[str]:
|
||||
def list_warnings(self, internet_available: bool) -> List[str]:
|
||||
warnings = []
|
||||
|
||||
if self.arch_distro:
|
||||
|
||||
@@ -248,7 +248,7 @@ class FlatpakManager(SoftwareManager):
|
||||
|
||||
return updates
|
||||
|
||||
def list_warnings(self) -> List[str]:
|
||||
def list_warnings(self, internet_available: bool) -> List[str]:
|
||||
if flatpak.is_installed():
|
||||
if not flatpak.has_remotes_set():
|
||||
return [self.i18n['flatpak.notification.no_remotes']]
|
||||
|
||||
@@ -196,17 +196,18 @@ class SnapManager(SoftwareManager):
|
||||
def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
|
||||
pass
|
||||
|
||||
def list_warnings(self) -> List[str]:
|
||||
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']))]
|
||||
|
||||
available, output = snap.is_api_available()
|
||||
if 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))
|
||||
|
||||
@@ -307,13 +307,15 @@ class GenericSoftwareManager(SoftwareManager):
|
||||
|
||||
return updates
|
||||
|
||||
def list_warnings(self) -> List[str]:
|
||||
def list_warnings(self, internet_available: bool = None) -> List[str]:
|
||||
warnings = []
|
||||
|
||||
if self.managers:
|
||||
int_available = internet.is_available(self.context.http_client, self.context.logger)
|
||||
|
||||
for man in self.managers:
|
||||
if man.is_enabled():
|
||||
man_warnings = man.list_warnings()
|
||||
man_warnings = man.list_warnings(internet_available=int_available)
|
||||
|
||||
if man_warnings:
|
||||
if warnings is None:
|
||||
|
||||
Reference in New Issue
Block a user