showing a warning dialog when the application starts and **snapd** is unavailable

This commit is contained in:
Vinicius Moreira
2019-07-27 21:48:28 -03:00
parent 8f9f8d04db
commit 6b8ee68463
10 changed files with 67 additions and 14 deletions

View File

@@ -17,8 +17,8 @@ from fpakman.util.cache import Cache
class SnapManager(ApplicationManager):
def __init__(self, app_args: Namespace, api_cache: Cache, disk_cache: bool, http_session):
super(SnapManager, self).__init__(app_args=app_args)
def __init__(self, app_args: Namespace, api_cache: Cache, disk_cache: bool, http_session, locale_keys: dict):
super(SnapManager, self).__init__(app_args=app_args, locale_keys=locale_keys)
self.api_cache = api_cache
self.http_session = http_session
self.disk_cache = disk_cache
@@ -133,3 +133,7 @@ class SnapManager(ApplicationManager):
def list_updates(self) -> List[ApplicationUpdate]:
return []
def list_warnings(self) -> List[str]:
if snap.get_snapd_version() == 'unavailable':
return [self.locale_keys['snap.notification.snapd_unavailable']]

View File

@@ -9,7 +9,7 @@ BASE_CMD = 'snap'
def is_installed():
version = get_snapd_version()
return False if version is None else True
return False if version is None or version == 'unavailable' else True
def get_version():
@@ -27,7 +27,7 @@ def get_snapd_version():
if lines and len(lines) >= 2:
version = lines[1].split(' ')[-1].strip()
return version if version and version.lower() != 'unavailable' else None
return version.lower() if version else None
else:
return None