suggestions button implemented respecting already installed applications

This commit is contained in:
Vinícius Moreira
2019-12-23 13:04:51 -03:00
parent 4696fc34d4
commit c29b1a0252
13 changed files with 270 additions and 27 deletions

View File

@@ -147,7 +147,12 @@ class FlatpakManager(SoftwareManager):
return ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.update(pkg.ref)))
def uninstall(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool:
return ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.uninstall(pkg.ref)))
uninstalled = ProcessHandler(watcher).handle(SystemProcess(subproc=flatpak.uninstall(pkg.ref)))
if self.suggestions_cache:
self.suggestions_cache.delete(pkg.id)
return uninstalled
def get_info(self, app: FlatpakApplication) -> dict:
if app.installed:
@@ -272,12 +277,19 @@ class FlatpakManager(SoftwareManager):
return res
else:
self.logger.info("Mapping suggestions")
installed = {i.id for i in self.read_installed(disk_loader=None).installed} if filter_installed else None
for line in file.text.split('\n'):
if line:
if limit <= 0 or len(res) < limit:
sug = line.split('=')
appid, priority = sug[1], SuggestionPriority(int(sug[0]))
appid = sug[1].strip()
if installed and appid in installed:
continue
priority = SuggestionPriority(int(sug[0]))
cached_sug = self.suggestions_cache.get(appid)
if cached_sug:

View File

@@ -8,6 +8,7 @@ from bauh.api.exception import NoInternetException
from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess
BASE_CMD = 'flatpak'
RE_SEVERAL_SPACES = re.compile(r'\s+')
def get_app_info_fields(app_id: str, branch: str, fields: List[str] = [], check_runtime: bool = False):