From 3aa5c16f8dca393e86164963898bf47763c17914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Moreira?= Date: Mon, 13 Jan 2020 18:55:25 -0300 Subject: [PATCH] [fix][flatpak] not retrieving the history correctly for different instalation levels --- bauh/gems/flatpak/controller.py | 6 +++--- bauh/gems/flatpak/flatpak.py | 15 +++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index b384f09e..f97fe971 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -151,7 +151,7 @@ class FlatpakManager(SoftwareManager): return SearchResult(models, None, len(models)) def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: - pkg.commit = flatpak.get_commit(pkg.id, pkg.branch) + pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation) watcher.change_progress(10) watcher.change_substatus(self.i18n['flatpak.downgrade.commits']) @@ -190,7 +190,7 @@ class FlatpakManager(SoftwareManager): def get_info(self, app: FlatpakApplication) -> dict: if app.installed: - app_info = flatpak.get_app_info_fields(app.id, app.branch) + app_info = flatpak.get_app_info_fields(app.id, app.branch, app.installation) app_info['name'] = app.name app_info['type'] = 'runtime' if app.runtime else 'app' app_info['description'] = strip_html(app.description) if app.description else '' @@ -230,7 +230,7 @@ class FlatpakManager(SoftwareManager): return {} def get_history(self, pkg: FlatpakApplication) -> PackageHistory: - pkg.commit = flatpak.get_commit(pkg.id, pkg.branch) + pkg.commit = flatpak.get_commit(pkg.id, pkg.branch, pkg.installation) commits = flatpak.get_app_commits_data(pkg.ref, pkg.origin, pkg.installation) status_idx = 0 diff --git a/bauh/gems/flatpak/flatpak.py b/bauh/gems/flatpak/flatpak.py index d661a14d..471898de 100755 --- a/bauh/gems/flatpak/flatpak.py +++ b/bauh/gems/flatpak/flatpak.py @@ -2,18 +2,17 @@ import re import subprocess import traceback from datetime import datetime -from io import StringIO from typing import List, Dict, Set from bauh.api.exception import NoInternetException -from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess, SystemProcess +from bauh.commons.system import new_subprocess, run_cmd, new_root_subprocess, SimpleProcess 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): - info = re.findall(r'\w+:\s.+', get_app_info(app_id, branch)) +def get_app_info_fields(app_id: str, branch: str, installation: str, fields: List[str] = [], check_runtime: bool = False): + info = re.findall(r'\w+:\s.+', get_app_info(app_id, branch, installation)) data = {} fields_to_retrieve = len(fields) + (1 if check_runtime and 'ref' not in fields else 0) @@ -63,12 +62,12 @@ def get_version(): return res.split(' ')[1].strip() if res else None -def get_app_info(app_id: str, branch: str): - return run_cmd('{} info {} {}'.format(BASE_CMD, app_id, branch)) +def get_app_info(app_id: str, branch: str, installation: str): + return run_cmd('{} info {} {}'.format(BASE_CMD, app_id, branch, '--{}'.format(installation))) -def get_commit(app_id: str, branch: str) -> str: - info = new_subprocess([BASE_CMD, 'info', app_id, branch]) +def get_commit(app_id: str, branch: str, installation: str) -> str: + info = new_subprocess([BASE_CMD, 'info', app_id, branch, '--{}'.format(installation)]) for o in new_subprocess(['grep', 'Commit:', '--color=never'], stdin=info.stdout).stdout: if o: