mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 16:44:16 +02:00
[snap] fix: not showing Launch button after recent application installation
This commit is contained in:
@@ -125,7 +125,12 @@ class SnapManager(SoftwareManager):
|
|||||||
raise Exception("'get_history' is not supported by {}".format(pkg.__class__.__name__))
|
raise Exception("'get_history' is not supported by {}".format(pkg.__class__.__name__))
|
||||||
|
|
||||||
def install(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
def install(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher) -> bool:
|
||||||
return ProcessHandler(watcher).handle(SystemProcess(subproc=snap.install_and_stream(pkg.name, pkg.confinement, root_password)))
|
res = ProcessHandler(watcher).handle(SystemProcess(subproc=snap.install_and_stream(pkg.name, pkg.confinement, root_password)))
|
||||||
|
|
||||||
|
if res:
|
||||||
|
pkg.has_apps_field = snap.has_apps_field(pkg.name, self.ubuntu_distro)
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def is_enabled(self) -> bool:
|
def is_enabled(self) -> bool:
|
||||||
return self.enabled
|
return self.enabled
|
||||||
|
|||||||
@@ -98,12 +98,9 @@ def read_installed(ubuntu_distro: bool) -> List[dict]:
|
|||||||
if idx > 0 and app_str:
|
if idx > 0 and app_str:
|
||||||
apps.append(app_str_to_json(app_str))
|
apps.append(app_str_to_json(app_str))
|
||||||
|
|
||||||
if ubuntu_distro:
|
info_path = _get_app_info_path(ubuntu_distro)
|
||||||
path = '/snap/{}/current/meta/snap.yaml'
|
|
||||||
else:
|
|
||||||
path = '/var/lib/snapd/snap/{}/current/meta/snap.yaml'
|
|
||||||
|
|
||||||
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
|
idx = -1
|
||||||
for o in new_subprocess(['grep', '-E', '(summary|apps)', '--colour=never'], stdin=info_out).stdout:
|
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
|
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]:
|
def search(word: str, exact_name: bool = False) -> List[dict]:
|
||||||
apps = []
|
apps = []
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user