[snap] fix: not showing Launch button after recent application installation

This commit is contained in:
Vinicius Moreira
2019-10-17 18:03:06 -03:00
parent 6cdf4f5746
commit 7c31575329
2 changed files with 31 additions and 6 deletions

View File

@@ -98,12 +98,9 @@ def read_installed(ubuntu_distro: bool) -> List[dict]:
if idx > 0 and app_str:
apps.append(app_str_to_json(app_str))
if ubuntu_distro:
path = '/snap/{}/current/meta/snap.yaml'
else:
path = '/var/lib/snapd/snap/{}/current/meta/snap.yaml'
info_path = _get_app_info_path(ubuntu_distro)
info_out = new_subprocess(['cat', *[path.format(a['name']) for a in apps]]).stdout
info_out = new_subprocess(['cat', *[info_path.format(a['name']) for a in apps]]).stdout
idx = -1
for o in new_subprocess(['grep', '-E', '(summary|apps)', '--colour=never'], stdin=info_out).stdout:
@@ -119,6 +116,29 @@ def read_installed(ubuntu_distro: bool) -> List[dict]:
return apps
def _get_app_info_path(ubuntu_distro: bool) -> str:
if ubuntu_distro:
return '/snap/{}/current/meta/snap.yaml'
else:
return '/var/lib/snapd/snap/{}/current/meta/snap.yaml'
def has_apps_field(name: str, ubuntu_distro: bool) -> bool:
info_path = _get_app_info_path(ubuntu_distro)
info_out = new_subprocess(['cat', info_path.format(name)]).stdout
res = False
for o in new_subprocess(['grep', '-E', 'apps', '--colour=never'], stdin=info_out).stdout:
if o:
line = o.decode()
if line.startswith('apps:'):
res = True
return res
def search(word: str, exact_name: bool = False) -> List[dict]:
apps = []