mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
snaps -> Improved how the the application verification is done
This commit is contained in:
@@ -31,7 +31,7 @@ class SnapManager(SoftwareManager):
|
||||
app = SnapApplication(publisher=app_json.get('publisher'),
|
||||
rev=app_json.get('rev'),
|
||||
notes=app_json.get('notes'),
|
||||
app_type=app_json.get('type'),
|
||||
has_apps_field=app_json.get('apps_field', False),
|
||||
id=app_json.get('name'),
|
||||
name=app_json.get('name'),
|
||||
version=app_json.get('version'),
|
||||
|
||||
@@ -23,14 +23,14 @@ class SnapApplication(SoftwarePackage):
|
||||
|
||||
def __init__(self, id: str = None, name: str = None, version: str = None, latest_version: str = None,
|
||||
description: str = None, publisher: str = None, rev: str = None, notes: str = None,
|
||||
app_type: str = None, confinement: str = None):
|
||||
confinement: str = None, has_apps_field: bool = None):
|
||||
super(SnapApplication, self).__init__(id=id, name=name, version=version,
|
||||
latest_version=latest_version, description=description)
|
||||
self.publisher = publisher
|
||||
self.rev = rev
|
||||
self.notes = notes
|
||||
self.type = app_type
|
||||
self.confinement = confinement
|
||||
self.has_apps_field = has_apps_field
|
||||
|
||||
def has_history(self):
|
||||
return False
|
||||
@@ -50,8 +50,8 @@ class SnapApplication(SoftwarePackage):
|
||||
def get_type_icon_path(self):
|
||||
return self.get_default_icon_path()
|
||||
|
||||
def is_application(self):
|
||||
return not self.type and (self.name in KNOWN_APP_NAMES) or (self.name not in KNOWN_RUNTIME_NAMES and self.type not in KNOWN_RUNTIME_TYPES and not self._name_starts_with(KNOWN_RUNTIME_PREFIXES))
|
||||
def is_application(self) -> bool:
|
||||
return self.has_apps_field is None or self.has_apps_field
|
||||
|
||||
def _name_starts_with(self, words: set):
|
||||
for word in words:
|
||||
|
||||
@@ -101,7 +101,7 @@ def read_installed() -> List[dict]:
|
||||
info_out = new_subprocess(['cat', *['/var/lib/snapd/snap/{}/current/meta/snap.yaml'.format(a['name']) for a in apps]]).stdout
|
||||
|
||||
idx = -1
|
||||
for o in new_subprocess(['grep', '-E', '(summary|type)', '--colour=never'], stdin=info_out).stdout:
|
||||
for o in new_subprocess(['grep', '-E', '(summary|apps)', '--colour=never'], stdin=info_out).stdout:
|
||||
if o:
|
||||
line = o.decode()
|
||||
|
||||
@@ -109,7 +109,7 @@ def read_installed() -> List[dict]:
|
||||
idx += 1
|
||||
apps[idx]['summary'] = line.split(':')[1].strip()
|
||||
else:
|
||||
apps[idx]['type'] = line.split(':')[1].strip()
|
||||
apps[idx]['apps_field'] = True
|
||||
|
||||
return apps
|
||||
|
||||
|
||||
Reference in New Issue
Block a user