From 6678cb282afccb5815f208c88f1c9defbdce01be Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 8 Nov 2021 17:23:24 -0300 Subject: [PATCH 01/26] bumping version to 0.9.21 --- bauh/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/__init__.py b/bauh/__init__.py index 0cfce0e7..e15eed95 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.9.20' +__version__ = '0.9.21' __app_name__ = 'bauh' import os From e539eea6f6db3f1eb00f946fed27aa87d9986e91 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Mon, 8 Nov 2021 17:25:37 -0300 Subject: [PATCH 02/26] [view] fix: upgrade summary (not displaying the icon type for some applications) --- CHANGELOG.md | 5 +++++ bauh/view/qt/thread.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04623d7..7b24b96c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [0.9.21] 2021 +### Fixes +- UI + - upgrade summary: not displaying the icon type for some applications + ## [0.9.20] 2021-11-05 ### Improvements - AppImage: diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index aadb4758..0b2b0cb0 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -216,7 +216,7 @@ def _req_as_option(self, req: UpgradeRequirement, tooltip: bool = True, custom_t if not icon_path: icon_path = req.pkg.get_type_icon_path() - elif not os.path.isfile(icon_path) and QIcon.fromTheme(icon_path).isNull(): + elif not os.path.isfile(icon_path) or QIcon.fromTheme(icon_path).isNull(): icon_path = req.pkg.get_type_icon_path() else: From 8488b086e639b4756971b204cb28e2038215c74e Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 11:47:36 -0300 Subject: [PATCH 03/26] [flatpak] fix: not displaying update components not associated with installed packages --- CHANGELOG.md | 3 + bauh/gems/flatpak/controller.py | 123 ++++++++++++++++++++------------ bauh/gems/flatpak/flatpak.py | 9 ++- bauh/gems/flatpak/model.py | 43 +++++++---- 4 files changed, 116 insertions(+), 62 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b24b96c..072aa32b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.21] 2021 ### Fixes +- Flatpak + - not displaying update components not associated with installed packages + - UI - upgrade summary: not displaying the icon type for some applications diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 56bd9633..360f4395 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -128,48 +128,63 @@ def read_installed(self, disk_loader: Optional[DiskCacheLoader], limit: int = -1 thread_updates = None installed = flatpak.list_installed(version) - models = [] - if installed: - update_map = None - if thread_updates: - thread_updates.join() - update_map = updates[0] + update_map = None + if thread_updates: + thread_updates.join() + update_map = updates[0] + + models = {} + if installed: for app_json in installed: model = self._map_to_model(app_json=app_json, installed=True, disk_loader=disk_loader, internet=internet_available) - model.update = None - models.append(model) - - if update_map and (update_map['full'] or update_map['partial']): - if version >= VERSION_1_2: - update_id = '{}/{}/{}'.format(app_json['id'], app_json['branch'], app_json['installation']) - - if update_map['full'] and update_id in update_map['full']: - model.update = True - - if update_map['partial']: - for partial in update_map['partial']: - partial_data = partial.split('/') - if app_json['id'] in partial_data[0] and\ - app_json['branch'] == partial_data[1] and\ - app_json['installation'] == partial_data[2]: - partial_model = model.gen_partial(partial.split('/')[0]) - partial_model.update = True - models.append(partial_model) - else: - model.update = '{}/{}'.format(app_json['installation'], app_json['ref']) in update_map['full'] + model.update = False + models[model.get_update_id(version)] = model + + if update_map: + for update_id in update_map['full']: + model_with_update = models.get(update_id) + if model_with_update: + model_with_update.update = True + else: + # it is a new component that must be installed + update_id_split = update_id.split('/') + new_app = FlatpakApplication(id=update_id_split[0], + branch=update_id_split[1], + installation=update_id_split[2], + name=update_id_split[0].split('.')[-1].strip(), + version=update_id_split[1], + arch='x86_64' if self.context.is_system_x86_64() else 'x86', + origin=update_id_split[3] if len(update_id_split) == 4 else None) + new_app.update_component = True # mark as "update component" + new_app.installed = True # faking the "installed" status to be displayed as an update + new_app.update = True + new_app.update_ref() + models[update_id] = new_app + + if version >= VERSION_1_2: + for partial_update_id in update_map['partial']: + partial_data = partial_update_id.split['/'] + + for model_update_id, model in models.items(): + if model.installation == partial_data[2] and model_update_id in partial_data[0] and \ + model.branch == partial_data[1]: + partial_model = model.gen_partial(partial_data[0]) + partial_model.update = True + models[partial_update_id] = partial_model + break if models: ignored = self._read_ignored_updates() if ignored: - for model in models: + for model in models.values(): if model.get_update_ignore_key() in ignored: model.updates_ignored = True - return SearchResult(models, None, len(models)) + return SearchResult([*models.values()], None, len(models)) def downgrade(self, pkg: FlatpakApplication, root_password: str, watcher: ProcessWatcher) -> bool: if not self._make_exports_dir(watcher): @@ -217,10 +232,16 @@ def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher ref = req.pkg.base_ref try: - res, _ = ProcessHandler(watcher).handle_simple(flatpak.update(app_ref=ref, - installation=req.pkg.installation, - related=related, - deps=deps)) + if req.pkg.update_component: + res, _ = ProcessHandler(watcher).handle_simple(flatpak.install(app_id=ref, + installation=req.pkg.installation, + origin=req.pkg.origin)) + + else: + res, _ = ProcessHandler(watcher).handle_simple(flatpak.update(app_ref=ref, + installation=req.pkg.installation, + related=related, + deps=deps)) watcher.change_substatus('') if not res: @@ -253,23 +274,33 @@ def uninstall(self, pkg: FlatpakApplication, root_password: str, watcher: Proces def get_info(self, app: FlatpakApplication) -> dict: if app.installed: - version = flatpak.get_version() - id_ = app.base_id if app.partial and version < VERSION_1_5 else app.id - app_info = flatpak.get_app_info_fields(id_, app.branch, app.installation) + if app.update_component: + app_info = {'id': app.id, + 'name': app.name, + 'branch': app.branch, + 'installation': app.installation, + 'origin': app.origin, + 'arch': app.arch, + 'ref': app.ref, + 'type': self.i18n['unknown']} + else: + version = flatpak.get_version() + id_ = app.base_id if app.partial and version < VERSION_1_5 else app.id + app_info = flatpak.get_app_info_fields(id_, app.branch, app.installation) - if app.partial and version < VERSION_1_5: - app_info['id'] = app.id - app_info['ref'] = app.ref + if app.partial and version < VERSION_1_5: + app_info['id'] = app.id + app_info['ref'] = app.ref - 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 '' + 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 '' - if app.installation: - app_info['installation'] = app.installation + if app.installation: + app_info['installation'] = app.installation - if app_info.get('installed'): - app_info['installed'] = app_info['installed'].replace('?', ' ') + if app_info.get('installed'): + app_info['installed'] = app_info['installed'].replace('?', ' ') return app_info else: diff --git a/bauh/gems/flatpak/flatpak.py b/bauh/gems/flatpak/flatpak.py index b185ea42..37f3eb2f 100755 --- a/bauh/gems/flatpak/flatpak.py +++ b/bauh/gems/flatpak/flatpak.py @@ -15,6 +15,7 @@ RE_SEVERAL_SPACES = re.compile(r'\s+') RE_COMMIT = re.compile(r'(Latest commit|Commit)\s*:\s*(.+)') +OPERATION_UPDATE_SYMBOLS = {'i', 'u'} def get_app_info_fields(app_id: str, branch: str, installation: str, fields: List[str] = [], check_runtime: bool = False): @@ -208,12 +209,14 @@ def read_updates(version: Version, installation: str) -> Dict[str, set]: if len(line_split) > 2: if version >= VERSION_1_5: - update_id = '{}/{}/{}'.format(line_split[2], line_split[3], installation) + update_id = f'{line_split[2]}/{line_split[3]}/{installation}/{line_split[5]}' + elif version >= VERSION_1_2: + update_id = f'{line_split[2]}/{line_split[4]}/{installation}/{line_split[5]}' else: update_id = '{}/{}/{}'.format(line_split[2], line_split[4], installation) - if len(line_split) >= 6: - if line_split[4] != 'i': + if version >= VERSION_1_3 and len(line_split) >= 6: + if line_split[4].strip().lower() in OPERATION_UPDATE_SYMBOLS: if '(partial)' in line_split[-1]: res['partial'].add(update_id) else: diff --git a/bauh/gems/flatpak/model.py b/bauh/gems/flatpak/model.py index cf0b519e..7a6a8d9c 100644 --- a/bauh/gems/flatpak/model.py +++ b/bauh/gems/flatpak/model.py @@ -1,6 +1,8 @@ +from packaging.version import Version + from bauh.api.abstract.model import SoftwarePackage, PackageStatus from bauh.commons import resource -from bauh.gems.flatpak import ROOT_DIR +from bauh.gems.flatpak import ROOT_DIR, VERSION_1_2, VERSION_1_5 from bauh.view.util.translation import I18n @@ -23,6 +25,7 @@ def __init__(self, id: str = None, name: str = None, version: str = None, latest self.base_id = None self.base_ref = None self.updates_ignored = updates_ignored + self.update_component = False # if it is a new app/runtime that has come as an update if runtime: self.categories = ['runtime'] @@ -31,13 +34,13 @@ def is_incomplete(self): return self.description is None and self.icon_url def has_history(self) -> bool: - return not self.partial and self.installed and self.ref + return not self.partial and not self.update_component and self.installed and self.ref def has_info(self): return bool(self.id) def can_be_downgraded(self): - return not self.partial and self.installed and self.ref + return not self.partial and not self.update_component and self.installed and self.ref def get_type(self): return 'flatpak' @@ -49,20 +52,21 @@ def get_type_icon_path(self): return self.get_default_icon_path() def is_application(self): - return not self.runtime and not self.partial + return not self.runtime and not self.partial and not self.update_component def get_disk_cache_path(self): return super(FlatpakApplication, self).get_disk_cache_path() + '/installed/' + self.id def get_data_to_cache(self): - return { - 'description': self.description, - 'icon_url': self.icon_url, - 'latest_version': self.latest_version, - 'version': self.version, - 'name': self.name, - 'categories': self.categories - } + if not self.update_component: + return { + 'description': self.description, + 'icon_url': self.icon_url, + 'latest_version': self.latest_version, + 'version': self.version, + 'name': self.name, + 'categories': self.categories + } def fill_cached_data(self, data: dict): for attr in self.get_data_to_cache().keys(): @@ -70,7 +74,7 @@ def fill_cached_data(self, data: dict): setattr(self, attr, data[attr]) def can_be_run(self) -> bool: - return self.installed and not self.runtime and not self.partial + return self.installed and not self.runtime and not self.partial and not self.update_component def get_publisher(self): return self.origin @@ -124,3 +128,16 @@ def __eq__(self, other): def get_disk_icon_path(self) -> str: if not self.runtime: return super(FlatpakApplication, self).get_disk_icon_path() + + def get_update_id(self, flatpak_version: Version) -> str: + if flatpak_version >= VERSION_1_2: + return f'{self.id}/{self.branch}/{self.installation}/{self.origin}' + else: + return f'{self.installation}/{self.ref}' + + def can_be_uninstalled(self) -> bool: + return not self.update_component and super(FlatpakApplication, self).can_be_uninstalled() + + def update_ref(self): + if self.id and self.arch and self.branch: + self.ref = f'{self.id}/{self.arch}/{self.branch}' From d68bf1e53da64986e8ac71bb48768e705f8c7b4f Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 12:28:41 -0300 Subject: [PATCH 04/26] [flatpak] fix: not displaying the updates size for Flatpak 1.2 --- CHANGELOG.md | 1 + bauh/gems/flatpak/flatpak.py | 18 ++++++++++++------ tests/gems/flatpak/test_flatpak.py | 21 +++++++++++++++++++++ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 tests/gems/flatpak/test_flatpak.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 072aa32b..bd1777bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixes - Flatpak - not displaying update components not associated with installed packages + - not displaying the updates size for Flatpak 1.2 - UI - upgrade summary: not displaying the icon type for some applications diff --git a/bauh/gems/flatpak/flatpak.py b/bauh/gems/flatpak/flatpak.py index 37f3eb2f..8586af4c 100755 --- a/bauh/gems/flatpak/flatpak.py +++ b/bauh/gems/flatpak/flatpak.py @@ -399,10 +399,10 @@ def run(app_id: str): def map_update_download_size(app_ids: Iterable[str], installation: str, version: Version) -> Dict[str, int]: success, output = ProcessHandler().handle_simple(SimpleProcess(['flatpak', 'update', '--{}'.format(installation)])) - if version >= VERSION_1_5: + if version >= VERSION_1_2: res = {} p = re.compile(r'^\d+.\t') - p2 = re.compile(r'\s([0-9.?a-zA-Z]+)\s?') + p2 = re.compile(r'([0-9.?a-zA-Z]+\s?)') for l in output.split('\n'): if l: line = l.strip() @@ -420,11 +420,17 @@ def map_update_download_size(app_ids: Iterable[str], installation: str, version: size_tuple = p2.findall(line_split[6]) if size_tuple: - size = size_tuple[0].split('?') - - if size and len(size) > 1: + if version >= VERSION_1_5: + size = size_tuple[0].split('?') + + if size and len(size) > 1: + try: + res[related_id[0].strip()] = size_to_byte(float(size[0]), size[1].strip()) + except: + traceback.print_exc() + else: try: - res[related_id[0].strip()] = size_to_byte(float(size[0]), size[1]) + res[related_id[0].strip()] = size_to_byte(float(size_tuple[0]), size_tuple[1].strip()) except: traceback.print_exc() return res diff --git a/tests/gems/flatpak/test_flatpak.py b/tests/gems/flatpak/test_flatpak.py new file mode 100644 index 00000000..7e10df91 --- /dev/null +++ b/tests/gems/flatpak/test_flatpak.py @@ -0,0 +1,21 @@ +from unittest import TestCase +from unittest.mock import patch, Mock + +from bauh import __app_name__ +from bauh.gems.flatpak import flatpak, VERSION_1_2 + + +class FlatpakTest(TestCase): + + @patch(f'{__app_name__}.gems.flatpak.flatpak.ProcessHandler.handle_simple', return_value=(True, """ + Looking for updates... + + \tID\tArch\tBranch\tRemote\tDownload + 1.\t \torg.xpto.Xnote\tx86_64\tstable\tflathub\t< 4.3 MB + + """)) + def test_map_update_download_size__for_flatpak_1_2(self, handle_simple: Mock): + download_size = flatpak.map_update_download_size(app_ids={'org.xpto.Xnote'}, installation='user', version=VERSION_1_2) + handle_simple.assert_called_once() + + self.assertEqual({'org.xpto.Xnote': 4300000}, download_size) From 0a9133068e6cfa20fcbec8dd76e5f27f9a420dae Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 12:47:13 -0300 Subject: [PATCH 05/26] [view] fix: displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies --- CHANGELOG.md | 3 ++- bauh/api/abstract/controller.py | 2 +- bauh/gems/arch/controller.py | 17 +++-------------- bauh/gems/flatpak/controller.py | 4 ++-- bauh/gems/snap/controller.py | 27 +++++++++++++-------------- bauh/gems/web/controller.py | 2 +- bauh/view/core/controller.py | 2 +- 7 files changed, 23 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1777bc..e3af2611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - not displaying the updates size for Flatpak 1.2 - UI - - upgrade summary: not displaying the icon type for some applications + - upgrade summary: not displaying the icon type for some applications + - displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies ## [0.9.20] 2021-11-05 ### Improvements diff --git a/bauh/api/abstract/controller.py b/bauh/api/abstract/controller.py index 4fbe1635..7c009539 100644 --- a/bauh/api/abstract/controller.py +++ b/bauh/api/abstract/controller.py @@ -318,7 +318,7 @@ def list_updates(self, internet_available: bool) -> List[PackageUpdate]: pass @abstractmethod - def list_warnings(self, internet_available: bool) -> List[str]: + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: """ :param internet_available :return: a list of warnings to be shown to the user diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index c9bdf3ce..509a9066 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2733,20 +2733,9 @@ def list_updates(self, internet_available: bool) -> List[PackageUpdate]: return [PackageUpdate(p.name, p.latest_version, aur_type if p.repository == 'aur' else repo_type, p.name) for p in installed if p.update and not p.is_update_ignored()] - def list_warnings(self, internet_available: bool) -> List[str]: - warnings = [] - - if self.arch_distro: - if not pacman.is_available(): - warnings.append(self.i18n['arch.warning.disabled'].format(bold('pacman'))) - - if not self._is_wget_available(): - warnings.append(self.i18n['arch.warning.disabled'].format(bold('wget'))) - - if not git.is_installed(): - warnings.append(self.i18n['arch.warning.git'].format(bold('git'))) - - return warnings + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + if not git.is_installed(): + return [self.i18n['arch.warning.git'].format(bold('git'))] def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]: self.logger.info("Downloading suggestions file {}".format(SUGGESTIONS_FILE)) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 360f4395..b57d95af 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -517,8 +517,8 @@ def list_updates(self, internet_available: bool) -> List[PackageUpdate]: return updates - def list_warnings(self, internet_available: bool) -> List[str]: - return [] + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + pass def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]: cli_version = flatpak.get_version() diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index db8dcb53..fc8c7b67 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -317,20 +317,19 @@ def prepare(self, task_manager: TaskManager, root_password: str, internet_availa def list_updates(self, internet_available: bool) -> List[PackageUpdate]: pass - def list_warnings(self, internet_available: bool) -> List[str]: - if snap.is_installed(): - if not snapd.is_running(): - snap_bold = bold('Snap') - return [self.i18n['snap.notification.snapd_unavailable'].format(bold('snapd'), snap_bold), - self.i18n['snap.notification.snap.disable'].format(snap_bold, bold('{} > {}'.format(self.i18n['settings'].capitalize(), - self.i18n['core.config.tab.types'])))] - - elif internet_available: - available, output = snap.is_api_available() - - if not available: - self.logger.warning('It seems Snap API is not available. Search output: {}'.format(output)) - return [self.i18n['snap.notifications.api.unavailable'].format(bold('Snaps'), bold('Snap'))] + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: + if not snapd.is_running(): + snap_bold = bold('Snap') + return [self.i18n['snap.notification.snapd_unavailable'].format(bold('snapd'), snap_bold), + self.i18n['snap.notification.snap.disable'].format(snap_bold, bold( + '{} > {}'.format(self.i18n['settings'].capitalize(), + self.i18n['core.config.tab.types'])))] + elif internet_available: + available, output = snap.is_api_available() + + if not available: + self.logger.warning('It seems Snap API is not available. Search output: {}'.format(output)) + return [self.i18n['snap.notifications.api.unavailable'].format(bold('Snaps'), bold('Snap'))] def _fill_suggestion(self, name: str, priority: SuggestionPriority, snapd_client: SnapdClient, out: List[PackageSuggestion]): res = snapd_client.find_by_name(name) diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index 66fd8cb1..8d67ec72 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -848,7 +848,7 @@ def prepare(self, task_manager: TaskManager, root_password: str, internet_availa def list_updates(self, internet_available: bool) -> List[PackageUpdate]: pass - def list_warnings(self, internet_available: bool) -> List[str]: + def list_warnings(self, internet_available: bool) -> Optional[List[str]]: pass def _fill_suggestion(self, app: WebApplication): diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index ac0e2159..6e4ccdcd 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -461,7 +461,7 @@ def list_warnings(self, internet_available: bool = None) -> List[str]: if self.managers: for man in self.managers: - if man.is_enabled(): + if self._can_work(man): man_warnings = man.list_warnings(internet_available=int_available) if man_warnings: From 6bc30ba516441523eb237d47d46efe6b93b35e66 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 12:48:22 -0300 Subject: [PATCH 06/26] [core.controller] refactoring: removing useless check --- bauh/view/core/controller.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index 6e4ccdcd..16a74eb9 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -465,9 +465,6 @@ def list_warnings(self, internet_available: bool = None) -> List[str]: man_warnings = man.list_warnings(internet_available=int_available) if man_warnings: - if warnings is None: - warnings = [] - warnings.extend(man_warnings) return warnings From 35ca24b680fb30ba2c831bc17f1a7c409f536d31 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 12:51:56 -0300 Subject: [PATCH 07/26] [arch] refactoring: i18n (warning: AUR missing deps) --- bauh/gems/arch/controller.py | 2 +- bauh/gems/arch/resources/locale/ca | 2 +- bauh/gems/arch/resources/locale/de | 2 +- bauh/gems/arch/resources/locale/en | 2 +- bauh/gems/arch/resources/locale/es | 2 +- bauh/gems/arch/resources/locale/fr | 2 +- bauh/gems/arch/resources/locale/it | 2 +- bauh/gems/arch/resources/locale/pt | 2 +- bauh/gems/arch/resources/locale/ru | 2 +- bauh/gems/arch/resources/locale/tr | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 509a9066..3839b1e8 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -2735,7 +2735,7 @@ def list_updates(self, internet_available: bool) -> List[PackageUpdate]: def list_warnings(self, internet_available: bool) -> Optional[List[str]]: if not git.is_installed(): - return [self.i18n['arch.warning.git'].format(bold('git'))] + return [self.i18n['arch.warning.aur_missing_dep'].format(bold('git'))] def list_suggestions(self, limit: int, filter_installed: bool) -> List[PackageSuggestion]: self.logger.info("Downloading suggestions file {}".format(SUGGESTIONS_FILE)) diff --git a/bauh/gems/arch/resources/locale/ca b/bauh/gems/arch/resources/locale/ca index 29ae0f2c..3075d0bb 100644 --- a/bauh/gems/arch/resources/locale/ca +++ b/bauh/gems/arch/resources/locale/ca @@ -276,7 +276,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled=Sembla que no s’ha instal·lat {}. No podreu gestionar paquets Arch/AUR. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=versió arch_repo.history.2_release=publicació arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/de b/bauh/gems/arch/resources/locale/de index e5a30ae0..169854ed 100644 --- a/bauh/gems/arch/resources/locale/de +++ b/bauh/gems/arch/resources/locale/de @@ -276,7 +276,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} scheint nicht intstalliert zu sein. Die Verwaltung von Arch / AUR Pakten wird nicht möglich sein. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=Version arch_repo.history.2_release=Release arch_repo.history.3_date=Datum diff --git a/bauh/gems/arch/resources/locale/en b/bauh/gems/arch/resources/locale/en index 6401202a..42d40bbd 100644 --- a/bauh/gems/arch/resources/locale/en +++ b/bauh/gems/arch/resources/locale/en @@ -276,7 +276,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} seems not to be installed. It will not be possible to manage Arch / AUR packages. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=release arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/es b/bauh/gems/arch/resources/locale/es index 20f7dfde..d46548bb 100644 --- a/bauh/gems/arch/resources/locale/es +++ b/bauh/gems/arch/resources/locale/es @@ -276,7 +276,7 @@ arch.upgrade.success=Paquete {} actualizado con éxito arch.upgrade.upgrade_aur_pkgs=Actualizando paquetes de AUR arch.upgrade.upgrade_repo_pkgs=Actualizando paquetes de repositorios arch.warning.disabled={} parece no estar instalado. No será posible administrar paquetes Arch / AUR. -arch.warning.git={} parece no estar instalado. No será posible administrar paquetes del AUR. +arch.warning.aur_missing_dep={} parece no estar instalado. No será posible administrar paquetes del AUR. arch_repo.history.1_version=versión arch_repo.history.2_release=lanzamiento arch_repo.history.3_date=fecha diff --git a/bauh/gems/arch/resources/locale/fr b/bauh/gems/arch/resources/locale/fr index b779f65a..a9c76178 100644 --- a/bauh/gems/arch/resources/locale/fr +++ b/bauh/gems/arch/resources/locale/fr @@ -276,7 +276,7 @@ arch.upgrade.success=Paquet {} mis à jour avec succès arch.upgrade.upgrade_aur_pkgs=Mise à jour des paquets AUR arch.upgrade.upgrade_repo_pkgs=Mise à jour des paquets de dépots arch.warning.disabled={} n'a pas l'air d'être installé. Il ne sera pas possible de gérer les paquets Arch / AUR. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=livraison arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/it b/bauh/gems/arch/resources/locale/it index 442a25d8..0a86345f 100644 --- a/bauh/gems/arch/resources/locale/it +++ b/bauh/gems/arch/resources/locale/it @@ -276,7 +276,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} sembra non essere installato. Non sarà possibile gestire i pacchetti Arch/AUR. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=versione arch_repo.history.2_release=rilascio arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/pt b/bauh/gems/arch/resources/locale/pt index 2b7f1402..7f1c2783 100644 --- a/bauh/gems/arch/resources/locale/pt +++ b/bauh/gems/arch/resources/locale/pt @@ -275,7 +275,7 @@ arch.upgrade.success=Pacote {} atualizado com sucesso arch.upgrade.upgrade_aur_pkgs=Atualizando pacotes do AUR arch.upgrade.upgrade_repo_pkgs=Atualizando pacotes dos repositórios arch.warning.disabled={} parece não estar instalado. Não será possível gerenciar pacotes Arch / AUR. -arch.warning.git={} parece não estar instalado. Não será possível gerenciar pacotes do AUR. +arch.warning.aur_missing_dep={} parece não estar instalado. Não será possível gerenciar pacotes do AUR. arch_repo.history.1_version=versão arch_repo.history.2_release=lançamento arch_repo.history.3_date=data diff --git a/bauh/gems/arch/resources/locale/ru b/bauh/gems/arch/resources/locale/ru index 78098486..f91ce42e 100644 --- a/bauh/gems/arch/resources/locale/ru +++ b/bauh/gems/arch/resources/locale/ru @@ -276,7 +276,7 @@ arch.upgrade.success=Package {} successfully upgraded arch.upgrade.upgrade_aur_pkgs=Upgrading AUR packages arch.upgrade.upgrade_repo_pkgs=Upgrading packages from repositories arch.warning.disabled={} кажется, не установлен. Управлять пакетами Arch / AUR будет невозможно. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=version arch_repo.history.2_release=release arch_repo.history.3_date=date diff --git a/bauh/gems/arch/resources/locale/tr b/bauh/gems/arch/resources/locale/tr index ffe30afb..720dc739 100644 --- a/bauh/gems/arch/resources/locale/tr +++ b/bauh/gems/arch/resources/locale/tr @@ -276,7 +276,7 @@ arch.upgrade.success={} paketi başarıyla yükseltildi arch.upgrade.upgrade_aur_pkgs=AUR paketleri yükseltiliyor arch.upgrade.upgrade_repo_pkgs=Resmi depo paketleri yükseltiliyor arch.warning.disabled={} kurulu değil gibi görünüyor. Arch / AUR paketlerini yönetmek mümkün olmayacaktır. -arch.warning.git={} seems not to be installed. It will not be possible to manage AUR packages. +arch.warning.aur_missing_dep={} seems not to be installed. It will not be possible to manage AUR packages. arch_repo.history.1_version=sürüm arch_repo.history.2_release=sürüm inşa arch_repo.history.3_date=tarih From 00fda5328726f4edf3592bbce44b83152f42c748 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 13:00:19 -0300 Subject: [PATCH 08/26] [flatpak] fix: partials split call --- bauh/gems/flatpak/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index b57d95af..700f1764 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -166,7 +166,7 @@ def read_installed(self, disk_loader: Optional[DiskCacheLoader], limit: int = -1 if version >= VERSION_1_2: for partial_update_id in update_map['partial']: - partial_data = partial_update_id.split['/'] + partial_data = partial_update_id.split('/') for model_update_id, model in models.items(): if model.installation == partial_data[2] and model_update_id in partial_data[0] and \ From 6e7c871b1a4aca988e434fb993e0f1805689f6be Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Tue, 9 Nov 2021 13:12:06 -0300 Subject: [PATCH 09/26] [flatpak] fix: not displaying updates for partials listed as installed apps/runtimes --- CHANGELOG.md | 1 + bauh/gems/flatpak/controller.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3af2611..7a508612 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Flatpak - not displaying update components not associated with installed packages - not displaying the updates size for Flatpak 1.2 + - not displaying updates for "partials" listed as installed apps/runtimes - UI - upgrade summary: not displaying the icon type for some applications diff --git a/bauh/gems/flatpak/controller.py b/bauh/gems/flatpak/controller.py index 700f1764..71b12a6f 100644 --- a/bauh/gems/flatpak/controller.py +++ b/bauh/gems/flatpak/controller.py @@ -168,13 +168,16 @@ def read_installed(self, disk_loader: Optional[DiskCacheLoader], limit: int = -1 for partial_update_id in update_map['partial']: partial_data = partial_update_id.split('/') - for model_update_id, model in models.items(): - if model.installation == partial_data[2] and model_update_id in partial_data[0] and \ - model.branch == partial_data[1]: - partial_model = model.gen_partial(partial_data[0]) - partial_model.update = True - models[partial_update_id] = partial_model - break + for model in models.values(): + if model.installation == partial_data[2] and model.branch == partial_data[1]: + if model.id == partial_data[0]: + model.update = True + break + elif model.id in partial_data[0]: + partial_model = model.gen_partial(partial_data[0]) + partial_model.update = True + models[partial_update_id] = partial_model + break if models: ignored = self._read_ignored_updates() From 7f89e04809d850c020898aae077da71187cc9113 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 11 Nov 2021 15:04:16 -0300 Subject: [PATCH 10/26] [commons/system] more fixes related to some backend commands hanging --- CHANGELOG.md | 2 ++ bauh/commons/system.py | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a508612..f9e9b5fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.9.21] 2021 ### Fixes +- General + - more fixes related to some backend commands hanging - Flatpak - not displaying update components not associated with installed packages - not displaying the updates size for Flatpak 1.2 diff --git a/bauh/commons/system.py b/bauh/commons/system.py index d3b106c1..ad7715d2 100644 --- a/bauh/commons/system.py +++ b/bauh/commons/system.py @@ -243,12 +243,10 @@ def new_subprocess(cmd: List[str], cwd: str = '.', shell: bool = False, stdin = "stderr": PIPE, "cwd": cwd, "shell": shell, - "env": gen_env(global_interpreter, lang, extra_paths) + "env": gen_env(global_interpreter, lang, extra_paths), + "stdin": stdin if stdin else subprocess.DEVNULL } - if input: - args['stdin'] = stdin - return subprocess.Popen(cmd, **args) From b95de102681344f3f3841101272da1c2b635cc7a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 11 Nov 2021 18:13:06 -0300 Subject: [PATCH 11/26] [commons/system] more fixes related to some backend commands hanging --- bauh/commons/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/commons/system.py b/bauh/commons/system.py index ad7715d2..3cbddbd8 100644 --- a/bauh/commons/system.py +++ b/bauh/commons/system.py @@ -295,7 +295,7 @@ def get_human_size_str(size) -> str: def run(cmd: List[str], success_code: int = 0) -> Tuple[bool, str]: - p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + p = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.DEVNULL) return p.returncode == success_code, p.stdout.decode() From b50b067158e18e50726b01bee598d7ffd50add25 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 17 Nov 2021 15:14:27 -0300 Subject: [PATCH 12/26] [view] fix: crashing when QT components sizes are not integers --- CHANGELOG.md | 3 ++- bauh/view/qt/components.py | 32 ++++++++++++++++---------------- bauh/view/qt/info.py | 4 ++-- bauh/view/qt/prepare.py | 6 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f9e9b5fd..525e8250 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - UI - upgrade summary: not displaying the icon type for some applications - displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies - + - crashing when QT components sizes are not integers [#198](https://github.com/vinifmor/bauh/issues/198) + ## [0.9.20] 2021-11-05 ### Improvements - AppImage: diff --git a/bauh/view/qt/components.py b/bauh/view/qt/components.py index 5b0177e3..ac5b8072 100644 --- a/bauh/view/qt/components.py +++ b/bauh/view/qt/components.py @@ -340,7 +340,7 @@ def __init__(self, model: SingleSelectComponent): self.view().setCursor(QCursor(Qt.PointingHandCursor)) if model.max_width > 0: - self.setMaximumWidth(model.max_width) + self.setMaximumWidth(int(model.max_width)) for idx, op in enumerate(self.model.options): icon = QIcon(op.icon_path) if op.icon_path else QIcon() @@ -368,7 +368,7 @@ def __init__(self, model: SingleSelectComponent, parent: QWidget = None): self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) if model.max_width > 0: - self.setMaximumWidth(model.max_width) + self.setMaximumWidth(int(model.max_width)) grid = QGridLayout() self.setLayout(grid) @@ -393,7 +393,7 @@ def __init__(self, model: SingleSelectComponent, parent: QWidget = None): col += 1 if model.max_width <= 0: - self.setMaximumWidth(self.sizeHint().width()) + self.setMaximumWidth(int(self.sizeHint().width())) class RadioSelectQt(QGroupBox): @@ -472,7 +472,7 @@ def __init__(self, model: TextInputComponent): self.setLayout(QGridLayout()) if self.model.max_width > 0: - self.setMaximumWidth(self.model.max_width) + self.setMaximumWidth(int(self.model.max_width)) self.text_input = QLineEditObserver() if model.type == TextInputType.SINGLE_LINE else QPlainTextEditObserver() @@ -483,10 +483,10 @@ def __init__(self, model: TextInputComponent): self.text_input.setPlaceholderText(model.placeholder) if model.min_width >= 0: - self.text_input.setMinimumWidth(model.min_width) + self.text_input.setMinimumWidth(int(model.min_width)) if model.min_height >= 0: - self.text_input.setMinimumHeight(model.min_height) + self.text_input.setMinimumHeight(int(model.min_height)) if model.tooltip: self.text_input.setToolTip(model.tooltip) @@ -514,10 +514,10 @@ def __init__(self, model: MultipleSelectComponent, callback): self.setLayout(self._layout) if model.max_width > 0: - self.setMaximumWidth(model.max_width) + self.setMaximumWidth(int(model.max_width)) if model.max_height > 0: - self.setMaximumHeight(model.max_height) + self.setMaximumHeight(int(model.max_height)) if model.label: line = 1 @@ -567,10 +567,10 @@ def __init__(self, model: MultipleSelectComponent, parent: QWidget = None): self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) if model.max_width > 0: - self.setMaximumWidth(model.max_width) + self.setMaximumWidth(int(model.max_width)) if model.max_height > 0: - self.setMaximumHeight(model.max_height) + self.setMaximumHeight(int(model.max_height)) self._layout = QGridLayout() self.setLayout(self._layout) @@ -773,10 +773,10 @@ def _new_text_input(self, c: TextInputComponent) -> Tuple[QLabel, QLineEdit]: view = QLineEditObserver() if c.type == TextInputType.SINGLE_LINE else QPlainTextEditObserver() if c.min_width >= 0: - view.setMinimumWidth(c.min_width) + view.setMinimumWidth(int(c.min_width)) if c.min_height >= 0: - view.setMinimumHeight(c.min_height) + view.setMinimumHeight(int(c.min_height)) if c.only_int: view.setValidator(QIntValidator()) @@ -837,7 +837,7 @@ def _wrap(self, comp: QWidget, model: ViewComponent) -> QWidget: field_container.setLayout(QHBoxLayout()) if model.max_width > 0: - field_container.setMaximumWidth(model.max_width) + field_container.setMaximumWidth(int(model.max_width)) field_container.layout().addWidget(comp) return field_container @@ -847,7 +847,7 @@ def _new_file_chooser(self, c: FileChooserComponent) -> Tuple[QLabel, QLineEdit] chooser.setReadOnly(True) if c.max_width > 0: - chooser.setMaximumWidth(c.max_width) + chooser.setMaximumWidth(int(c.max_width)) if c.file_path: chooser.setText(c.file_path) @@ -940,7 +940,7 @@ def new_spacer(min_width: int = None) -> QWidget: spacer.setProperty('spacer', 'true') if min_width: - spacer.setMinimumWidth(min_width) + spacer.setMinimumWidth(int(min_width)) spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) return spacer @@ -986,7 +986,7 @@ def __init__(self, model: RangeInputComponent): self.layout().addWidget(QLabel(model.label.capitalize() + ' :' if model.label else ''), 0, 0) if self.model.max_width > 0: - self.setMaximumWidth(self.model.max_width) + self.setMaximumWidth(int(self.model.max_width)) self.spinner = QSpinBox() self.spinner.setCursor(QCursor(Qt.PointingHandCursor)) diff --git a/bauh/view/qt/info.py b/bauh/view/qt/info.py index 64c55c49..a3a1a56a 100644 --- a/bauh/view/qt/info.py +++ b/bauh/view/qt/info.py @@ -104,8 +104,8 @@ def __init__(self, pkg_info: dict, icon_cache: MemoryCache, i18n: I18n, screen_s lower_container.layout().addWidget(self.bt_close) layout.addWidget(lower_container) - self.setMinimumWidth(self.gbox_info.sizeHint().width() * 1.2) - self.setMaximumHeight(screen_size.height() * 0.8) + self.setMinimumWidth(int(self.gbox_info.sizeHint().width() * 1.2)) + self.setMaximumHeight(int(screen_size.height() * 0.8)) self.adjustSize() def _gen_show_button(self, idx: int, val): diff --git a/bauh/view/qt/prepare.py b/bauh/view/qt/prepare.py index 67f29b34..e31c78a5 100644 --- a/bauh/view/qt/prepare.py +++ b/bauh/view/qt/prepare.py @@ -153,9 +153,9 @@ def __init__(self, context: ApplicationContext, manager: SoftwareManager, screen self.app_config = app_config self.manage_window = manage_window self.setWindowTitle('{} ({})'.format(__app_name__, self.i18n['prepare_panel.title.start'].lower())) - self.setMinimumWidth(screen_size.width() * 0.5) - self.setMinimumHeight(screen_size.height() * 0.35) - self.setMaximumHeight(screen_size.height() * 0.95) + self.setMinimumWidth(int(screen_size.width() * 0.5)) + self.setMinimumHeight(int(screen_size.height() * 0.35)) + self.setMaximumHeight(int(screen_size.height() * 0.95)) self.setLayout(QVBoxLayout()) self.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) self.manager = manager From 46a3b466523ad47815bf49d1eb7be3044d3cbd4c Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 17 Nov 2021 15:36:21 -0300 Subject: [PATCH 13/26] [api] fix: crashing when trying to retrieve a file size without proving its URL --- CHANGELOG.md | 2 ++ bauh/api/http.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 525e8250..d013558e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixes - General - more fixes related to some backend commands hanging + - crashing when trying to retrieve a file size without proving its URL [#207](https://github.com/vinifmor/bauh/issues/207) + - Flatpak - not displaying update components not associated with installed packages - not displaying the updates size for Flatpak 1.2 diff --git a/bauh/api/http.py b/bauh/api/http.py index 1c459f2e..cc54d9d3 100644 --- a/bauh/api/http.py +++ b/bauh/api/http.py @@ -69,6 +69,9 @@ def get_yaml(self, url: str, params: dict = None, headers: dict = None, allow_re return yaml.safe_load(res.text) if res else None def get_content_length_in_bytes(self, url: str, session: bool = True) -> Optional[int]: + if not url: + return None + params = {'url': url, 'allow_redirects': True, 'stream': True} try: From e930a9796696824d24f2acead6369ea298d8c425 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Wed, 17 Nov 2021 15:49:10 -0300 Subject: [PATCH 14/26] [appimage] fix: displaying updates without the associated download URL for some applications --- CHANGELOG.md | 5 +++++ bauh/gems/appimage/controller.py | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d013558e..c4b7cb0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - General - more fixes related to some backend commands hanging - crashing when trying to retrieve a file size without proving its URL [#207](https://github.com/vinifmor/bauh/issues/207) + +- AppImage + - displaying updates without the associated download URL for some applications [#207](https://github.com/vinifmor/bauh/issues/207) - Flatpak - not displaying update components not associated with installed packages @@ -20,6 +23,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies - crashing when QT components sizes are not integers [#198](https://github.com/vinifmor/bauh/issues/198) + + ## [0.9.20] 2021-11-05 ### Improvements - AppImage: diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 44d3ce82..602f527a 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -279,16 +279,18 @@ def read_installed(self, disk_loader: Optional[DiskCacheLoader], limit: int = -1 if app.name.lower() == tup[0].lower() and (not app.github or app.github.lower() == tup[1].lower()): continuous_version = app.version == 'continuous' continuous_update = tup[2] == 'continuous' - if continuous_version and not continuous_update: - app.update = True - elif continuous_update and not continuous_version: - app.update = False - else: - try: - app.update = parse_version(tup[2]) > parse_version(app.version) if tup[2] else False - except: + + if tup[3]: + if continuous_version and not continuous_update: + app.update = True + elif continuous_update and not continuous_version: app.update = False - traceback.print_exc() + else: + try: + app.update = parse_version(tup[2]) > parse_version(app.version) if tup[2] else False + except: + app.update = False + traceback.print_exc() if app.update: app.latest_version = tup[2] From 65df7654f959295f2e69ae3f28c58e9cfc95a5dd Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 19 Nov 2021 17:01:41 -0300 Subject: [PATCH 15/26] [appimage] fix: uninstalling the application when an update download fails --- CHANGELOG.md | 1 + bauh/gems/appimage/__init__.py | 3 +- bauh/gems/appimage/controller.py | 84 ++++++++++++++++++++++++-------- bauh/view/resources/locale/ca | 2 + bauh/view/resources/locale/de | 2 + bauh/view/resources/locale/en | 2 + bauh/view/resources/locale/es | 2 + bauh/view/resources/locale/fr | 2 + bauh/view/resources/locale/it | 2 + bauh/view/resources/locale/pt | 2 + bauh/view/resources/locale/ru | 2 + bauh/view/resources/locale/tr | 2 + 12 files changed, 84 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4b7cb0c..cd3712c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AppImage - displaying updates without the associated download URL for some applications [#207](https://github.com/vinifmor/bauh/issues/207) + - uninstalling the application when an update download fails [#207](https://github.com/vinifmor/bauh/issues/207) - Flatpak - not displaying update components not associated with installed packages diff --git a/bauh/gems/appimage/__init__.py b/bauh/gems/appimage/__init__.py index aef041c2..3ecbc8c9 100644 --- a/bauh/gems/appimage/__init__.py +++ b/bauh/gems/appimage/__init__.py @@ -2,7 +2,7 @@ from pathlib import Path from typing import Optional -from bauh.api.constants import CONFIG_PATH, CACHE_PATH +from bauh.api.constants import CONFIG_PATH, CACHE_PATH, TEMP_DIR from bauh.commons import resource ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) @@ -21,6 +21,7 @@ DESKTOP_ENTRIES_PATH = '{}/.local/share/applications'.format(str(Path.home())) SUGGESTIONS_CACHED_FILE = '{}/suggestions.txt'.format(APPIMAGE_CACHE_PATH) SUGGESTIONS_CACHED_TS_FILE = '{}/suggestions.ts'.format(APPIMAGE_CACHE_PATH) +DOWNLOAD_DIR = f'{TEMP_DIR}/appimage/download' def get_icon_path() -> str: diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 602f527a..669acb6d 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -29,7 +29,7 @@ from bauh.commons.system import SystemProcess, new_subprocess, ProcessHandler, run_cmd, SimpleProcess from bauh.gems.appimage import query, INSTALLATION_PATH, LOCAL_PATH, ROOT_DIR, \ CONFIG_DIR, UPDATES_IGNORED_FILE, util, get_default_manual_installation_file_dir, DATABASE_APPS_FILE, \ - DATABASE_RELEASES_FILE, DESKTOP_ENTRIES_PATH, APPIMAGE_CACHE_PATH, get_icon_path + DATABASE_RELEASES_FILE, DESKTOP_ENTRIES_PATH, APPIMAGE_CACHE_PATH, get_icon_path, DOWNLOAD_DIR from bauh.gems.appimage.config import AppImageConfigManager from bauh.gems.appimage.model import AppImage from bauh.gems.appimage.util import replace_desktop_entry_exec_command @@ -356,6 +356,11 @@ def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher for req in requirements.to_upgrade: watcher.change_status("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], req.pkg.name, req.pkg.version)) + download_data = self._download(req.pkg, watcher) + + if not download_data: + return False + if not self.uninstall(req.pkg, root_password, watcher).success: watcher.show_message(title=self.i18n['error'], body=self.i18n['appimage.error.uninstall_current_version'], @@ -363,7 +368,7 @@ def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher watcher.change_substatus('') return False - if not self.install(req.pkg, root_password, None, watcher).success: + if not self._install(pkg=req.pkg, watcher=watcher, pre_downloaded_file=download_data).success: watcher.change_substatus('') return False @@ -488,9 +493,38 @@ def _find_icon_file(self, folder: str) -> str: if RE_ICON_ENDS_WITH.match(f): return f + def _download(self, pkg: AppImage, watcher: ProcessWatcher) -> Optional[Tuple[str, str]]: + appimage_url = pkg.url_download_latest_version if pkg.update else pkg.url_download + file_name = appimage_url.split('/')[-1] + pkg.version = pkg.latest_version + pkg.url_download = appimage_url + + try: + Path(DOWNLOAD_DIR).mkdir(exist_ok=True, parents=True) + except OSError: + watcher.show_message(title=self.i18n['error'], + body=self.i18n['error.mkdir'].format(dir=bold(DOWNLOAD_DIR)), + type_=MessageType.ERROR) + return + + file_path = f'{DOWNLOAD_DIR}/{file_name}' + downloaded = self.file_downloader.download(file_url=pkg.url_download, watcher=watcher, + output_path=file_path, cwd=str(Path.home())) + + if not downloaded: + watcher.show_message(title=self.i18n['error'], + body=self.i18n['appimage.install.download.error'].format(bold(pkg.url_download)), + type_=MessageType.ERROR) + return + + return file_name, file_path + def install(self, pkg: AppImage, root_password: str, disk_loader: Optional[DiskCacheLoader], watcher: ProcessWatcher) -> TransactionResult: - handler = ProcessHandler(watcher) + return self._install(pkg=pkg, watcher=watcher) + def _install(self, pkg: AppImage, watcher: ProcessWatcher, pre_downloaded_file: Optional[Tuple[str, str]] = None): + + handler = ProcessHandler(watcher) out_dir = INSTALLATION_PATH + pkg.get_clean_name() counter = 0 while True: @@ -518,35 +552,45 @@ def install(self, pkg: AppImage, root_password: str, disk_loader: Optional[DiskC if not moved: watcher.show_message(title=self.i18n['error'].capitalize(), - body=self.i18n['appimage.install.imported.rename_error'].format(bold(pkg.local_file_path.split('/')[-1]), bold(output)), + body=self.i18n['appimage.install.imported.rename_error'].format( + bold(pkg.local_file_path.split('/')[-1]), bold(output)), type_=MessageType.ERROR) return TransactionResult.fail() else: - appimage_url = pkg.url_download_latest_version if pkg.update else pkg.url_download - file_name = appimage_url.split('/')[-1] - pkg.version = pkg.latest_version - pkg.url_download = appimage_url + download_data = pre_downloaded_file if pre_downloaded_file else self._download(pkg, watcher) - file_path = out_dir + '/' + file_name - downloaded = self.file_downloader.download(file_url=pkg.url_download, watcher=watcher, - output_path=file_path, cwd=str(Path.home())) + if not download_data: + return TransactionResult.fail() + + file_name, download_path = download_data[0], download_data[1] + + install_file_path = f'{out_dir}/{file_name}' + + try: + shutil.move(download_path, install_file_path) + except OSError: + watcher.show_message(title=self.i18n['error'], + body=self.i18n['error.mvfile'].formmat(src=bold(download_path), + dest=bold(install_file_path))) + return TransactionResult.fail() - if downloaded: watcher.change_substatus(self.i18n['appimage.install.permission'].format(bold(file_name))) - permission_given = handler.handle(SystemProcess(new_subprocess(['chmod', 'a+x', file_path]))) + permission_given = handler.handle(SystemProcess(new_subprocess(['chmod', 'a+x', install_file_path]))) if permission_given: watcher.change_substatus(self.i18n['appimage.install.extract'].format(bold(file_name))) try: - res, output = handler.handle_simple(SimpleProcess([file_path, '--appimage-extract'], cwd=out_dir)) + res, output = handler.handle_simple( + SimpleProcess([install_file_path, '--appimage-extract'], cwd=out_dir)) if 'Error: Failed to register AppImage in AppImageLauncherFS' in output: watcher.show_message(title=self.i18n['error'], - body=self.i18n['appimage.install.appimagelauncher.error'].format(appimgl=bold('AppImageLauncher'), app=bold(pkg.name)), + body=self.i18n['appimage.install.appimagelauncher.error'].format( + appimgl=bold('AppImageLauncher'), app=bold(pkg.name)), type_=MessageType.ERROR) handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir]))) return TransactionResult.fail() @@ -570,7 +614,7 @@ def install(self, pkg: AppImage, root_password: str, disk_loader: Optional[DiskC if de_content: de_content = replace_desktop_entry_exec_command(desktop_entry=de_content, appname=pkg.name, - file_path=file_path) + file_path=install_file_path) extracted_icon = self._find_icon_file(extracted_folder) if extracted_icon: @@ -595,20 +639,18 @@ def install(self, pkg: AppImage, root_password: str, disk_loader: Optional[DiskC except: traceback.print_exc() - SymlinksVerifier.create_symlink(app=pkg, file_path=file_path, logger=self.logger, watcher=watcher) + SymlinksVerifier.create_symlink(app=pkg, file_path=install_file_path, logger=self.logger, + watcher=watcher) return TransactionResult(success=True, installed=[pkg], removed=[]) else: watcher.show_message(title=self.i18n['error'], body='Could extract content from {}'.format(bold(file_name)), type_=MessageType.ERROR) - else: - watcher.show_message(title=self.i18n['error'], - body=self.i18n['appimage.install.download.error'].format(bold(pkg.url_download)), - type_=MessageType.ERROR) handler.handle(SystemProcess(new_subprocess(['rm', '-rf', out_dir]))) return TransactionResult.fail() + def _gen_desktop_entry_path(self, app: AppImage) -> str: return '{}/bauh_appimage_{}.desktop'.format(DESKTOP_ENTRIES_PATH, app.get_clean_name()) diff --git a/bauh/view/resources/locale/ca b/bauh/view/resources/locale/ca index cbb8364c..6130cc83 100644 --- a/bauh/view/resources/locale/ca +++ b/bauh/view/resources/locale/ca @@ -255,6 +255,8 @@ downgraded=revertida download=download downloading=S’està baixant error=error +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=e.g exit=surt file=file diff --git a/bauh/view/resources/locale/de b/bauh/view/resources/locale/de index fbce3aa0..25810101 100644 --- a/bauh/view/resources/locale/de +++ b/bauh/view/resources/locale/de @@ -254,6 +254,8 @@ downgraded=gedowngraded download=Download downloading=Download error=Fehler +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=z.B. exit=Beenden file=file diff --git a/bauh/view/resources/locale/en b/bauh/view/resources/locale/en index 565c52f4..b34f41bf 100644 --- a/bauh/view/resources/locale/en +++ b/bauh/view/resources/locale/en @@ -254,6 +254,8 @@ downgraded=downgraded download=download downloading=Downloading error=error +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=e.g exit=exit file=file diff --git a/bauh/view/resources/locale/es b/bauh/view/resources/locale/es index 99eb8c7d..4f1b179a 100644 --- a/bauh/view/resources/locale/es +++ b/bauh/view/resources/locale/es @@ -255,6 +255,8 @@ downgraded=versión revertida download=descarga downloading=Descargando error=error +error.mkdir=No se pudo crear el directorio {dir} +error.mvfile=No se pudo mover {src} a {dest} example.short=p.ej exit=salir file=archivo diff --git a/bauh/view/resources/locale/fr b/bauh/view/resources/locale/fr index da412ec7..449e17a9 100644 --- a/bauh/view/resources/locale/fr +++ b/bauh/view/resources/locale/fr @@ -252,6 +252,8 @@ downgraded=downgradé download=télécharger downloading=Téléchargement en cours error=erreur +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=ex exit=sortir file=fichier diff --git a/bauh/view/resources/locale/it b/bauh/view/resources/locale/it index 88d58fe6..5d764ba1 100644 --- a/bauh/view/resources/locale/it +++ b/bauh/view/resources/locale/it @@ -256,6 +256,8 @@ downgraded=downgraded download=download downloading=Scaricamento error=errore +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=e.g exit=esci file=file diff --git a/bauh/view/resources/locale/pt b/bauh/view/resources/locale/pt index 2166889e..b185674a 100644 --- a/bauh/view/resources/locale/pt +++ b/bauh/view/resources/locale/pt @@ -254,6 +254,8 @@ downgraded=versão revertida download=download downloading=Baixando error=erro +error.mkdir=Não foi possível criar o diretório {dir} +error.mvfile=Não foi possível mover {src} para {dest} example.short=ex exit=sair file=arquivo diff --git a/bauh/view/resources/locale/ru b/bauh/view/resources/locale/ru index fe95fa32..7def1dab 100644 --- a/bauh/view/resources/locale/ru +++ b/bauh/view/resources/locale/ru @@ -254,6 +254,8 @@ downgraded=Произведён откат download=Загрузка downloading=Загрузка error=Ошибка +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=К примеру exit=Выход file=файл diff --git a/bauh/view/resources/locale/tr b/bauh/view/resources/locale/tr index 75821350..00406ce9 100644 --- a/bauh/view/resources/locale/tr +++ b/bauh/view/resources/locale/tr @@ -254,6 +254,8 @@ downgraded=düşürüldü download=indir downloading=İndiriliyor error=hata +error.mkdir=Could not create directory {dir} +error.mvfile=Could not move {src} to {dest} example.short=e.g exit=çıkış file=dosya From 93362878e30db0b645cbfe838c69ebdbb2d7f873 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 19 Nov 2021 17:22:14 -0300 Subject: [PATCH 16/26] [appimage] fix: uninstalling the application when download fails (dowgrading) --- CHANGELOG.md | 2 +- bauh/gems/appimage/controller.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd3712c1..36dfd201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - AppImage - displaying updates without the associated download URL for some applications [#207](https://github.com/vinifmor/bauh/issues/207) - - uninstalling the application when an update download fails [#207](https://github.com/vinifmor/bauh/issues/207) + - uninstalling the application when an update/downgrade download fails [#207](https://github.com/vinifmor/bauh/issues/207) - Flatpak - not displaying update components not associated with installed packages diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 669acb6d..94c4f8d1 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -333,12 +333,18 @@ def downgrade(self, pkg: AppImage, root_password: str, watcher: ProcessWatcher) type_=MessageType.ERROR) return False else: + old_release = versions.history[versions.pkg_status_idx + 1] + pkg.version = old_release['0_version'] + pkg.latest_version = pkg.version + pkg.url_download = old_release['2_url_download'] + + download_data = self._download(pkg=pkg, watcher=watcher) + + if not download_data: + return False + if self.uninstall(pkg, root_password, watcher).success: - old_release = versions.history[versions.pkg_status_idx + 1] - pkg.version = old_release['0_version'] - pkg.latest_version = pkg.version - pkg.url_download = old_release['2_url_download'] - if self.install(pkg, root_password, None, watcher).success: + if self._install(pkg=pkg, watcher=watcher, pre_downloaded_file=download_data).success: self.cache_to_disk(pkg, None, False) return True else: From 8b59c2ae77c094d4afdd0d3931c91b0ae7ec2775 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 19 Nov 2021 17:27:51 -0300 Subject: [PATCH 17/26] [appimage] refactoring: i18n key --- bauh/gems/appimage/controller.py | 2 +- bauh/gems/appimage/resources/locale/ca | 2 +- bauh/gems/appimage/resources/locale/de | 2 +- bauh/gems/appimage/resources/locale/en | 2 +- bauh/gems/appimage/resources/locale/es | 2 +- bauh/gems/appimage/resources/locale/pt | 2 +- bauh/gems/appimage/resources/locale/ru | 2 +- bauh/gems/appimage/resources/locale/tr | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index 94c4f8d1..d674e3c7 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -519,7 +519,7 @@ def _download(self, pkg: AppImage, watcher: ProcessWatcher) -> Optional[Tuple[st if not downloaded: watcher.show_message(title=self.i18n['error'], - body=self.i18n['appimage.install.download.error'].format(bold(pkg.url_download)), + body=self.i18n['appimage.download.error'].format(bold(pkg.url_download)), type_=MessageType.ERROR) return diff --git a/bauh/gems/appimage/resources/locale/ca b/bauh/gems/appimage/resources/locale/ca index c599010a..cb89108d 100644 --- a/bauh/gems/appimage/resources/locale/ca +++ b/bauh/gems/appimage/resources/locale/ca @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} té només una versió publicada. appimage.downgrade.impossible.title=No s’ha pogut revertir la versió appimage.downgrade.install_version=No s’ha pogut instal·lar la versió {} ({}) appimage.downgrade.unknown_version.body=No s’ha pogut identificar la versió actual de {} a l’historial de versions +appimage.download.error=No s’ha pogut baixar el fitxer {}. El servidor del fitxer pot estar inactiu. appimage.error.uninstall_current_version=It was not possible to uninstall the current version of {} appimage.history.0_version=versió appimage.history.1_published_at=data @@ -29,7 +30,6 @@ appimage.info.symlink=Symlink appimage.info.url_download=URL del fitxer appimage.install.appimagelauncher.error={appimgl} no permet la instal·lació de {app}. Desinstal·leu {appimgl}, reinicieu el sistema i torneu a provar d’instal·lar {app}. appimage.install.desktop_entry=S’està creant una drecera del menú -appimage.install.download.error=No s’ha pogut baixar el fitxer {}. El servidor del fitxer pot estar inactiu. appimage.install.extract=S’està extraient el contingut de {} appimage.install.imported.rename_error=It was not possible to move the file {} to {} appimage.install.permission=S’està concedint el permís d’execució a {} diff --git a/bauh/gems/appimage/resources/locale/de b/bauh/gems/appimage/resources/locale/de index 261b4add..f4b4659e 100644 --- a/bauh/gems/appimage/resources/locale/de +++ b/bauh/gems/appimage/resources/locale/de @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} hat nur eine veröffentliche Version appimage.downgrade.impossible.title=Downgrade nicht möglich appimage.downgrade.install_version=Die Installation der Version {} ({}) war nicht möglich appimage.downgrade.unknown_version.body=Die Identifikation der aktuellen Version von {} im Versionsverlauf war nicht möglich +appimage.download.error=Das Herunterladen der Datei {} ist fehlgeschlagen. Eventuell ist der Server nicht verfügbar appimage.error.uninstall_current_version=Deinstallation der aktuellen Version von {} war nicht möglich appimage.history.0_version=Version appimage.history.1_published_at=Datum @@ -29,7 +30,6 @@ appimage.info.symlink=Symlink appimage.info.url_download=Datei URL appimage.install.appimagelauncher.error={appimgl} verhindert die installation von {app}. Deinstalliere {appimgl}, starte deinen Computer neu und versuche die installation von {app} erneut. appimage.install.desktop_entry=Menü-Shortcut erstellen -appimage.install.download.error=Das Herunterladen der Datei {} ist fehlgeschlagen. Eventuell ist der Server nicht verfügbar appimage.install.extract=Entpacke Inhalt von {} appimage.install.imported.rename_error=It was not possible to move the file {} to {} appimage.install.permission=Ausführberechtigungen für {} diff --git a/bauh/gems/appimage/resources/locale/en b/bauh/gems/appimage/resources/locale/en index 174e6005..2c8097b4 100644 --- a/bauh/gems/appimage/resources/locale/en +++ b/bauh/gems/appimage/resources/locale/en @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} has only one published version. appimage.downgrade.impossible.title=Impossible to downgrade appimage.downgrade.install_version=It was not possible to install the version {} ({}) appimage.downgrade.unknown_version.body={} current version was not found in its release history +appimage.download.error=It was not possible to download the file {}. The file server can be down. appimage.error.uninstall_current_version=It was not possible to uninstall the current version of {} appimage.history.0_version=version appimage.history.1_published_at=date @@ -29,7 +30,6 @@ appimage.info.symlink=Symlink appimage.info.url_download=File URL appimage.install.appimagelauncher.error={appimgl} is not allowing {app} to be installed. Uninstall {appimgl}, reboot your system and try to install {app} again. appimage.install.desktop_entry=Generating a menu shortcut -appimage.install.download.error=It was not possible to download the file {}. The file server can be down. appimage.install.extract=Extracting the content from {} appimage.install.imported.rename_error=It was not possible to move the file {} to {} appimage.install.permission=Giving execution permission to {} diff --git a/bauh/gems/appimage/resources/locale/es b/bauh/gems/appimage/resources/locale/es index 882852c8..8232058f 100644 --- a/bauh/gems/appimage/resources/locale/es +++ b/bauh/gems/appimage/resources/locale/es @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} solo tiene una versión publicada. appimage.downgrade.impossible.title=Imposible revertir la versión appimage.downgrade.install_version=No fue posible instalar la versión {} ({}) appimage.downgrade.unknown_version.body=No fue posible identificar la versión actual de {} en su historial de versiones +appimage.download.error=No fue posible descargar el archivo {}. El servidor del archivo puede estar inactivo. appimage.error.uninstall_current_version=It was not possible to uninstall the current version of {} appimage.history.0_version=versión appimage.history.1_published_at=fecha @@ -29,7 +30,6 @@ appimage.info.symlink=Link simbólico appimage.info.url_download=URL del archivo appimage.install.appimagelauncher.error={appimgl} no permite la instalación de {app}. Desinstale {appimgl}, reinicie su sistema e intente instalar {app} nuevamente. appimage.install.desktop_entry=Creando un atajo en el menú -appimage.install.download.error=No fue posible descargar el archivo {}. El servidor del archivo puede estar inactivo. appimage.install.extract=Extrayendo el contenido de {} appimage.install.imported.rename_error=No fue posible mover el archivo {} a {} appimage.install.permission=Concediendo permiso de ejecución a {} diff --git a/bauh/gems/appimage/resources/locale/pt b/bauh/gems/appimage/resources/locale/pt index a63b7fd3..0575edd9 100644 --- a/bauh/gems/appimage/resources/locale/pt +++ b/bauh/gems/appimage/resources/locale/pt @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} tem somente uma versão publicada. appimage.downgrade.impossible.title=Impossível reverter a versão appimage.downgrade.install_version=Não foi possivel instalar a versão {} ({}) appimage.downgrade.unknown_version.body=Não foi possível identificar a versão atual de {} no seu histórico de versões +appimage.download.error=Não foi possível baixar o arquivo {}. O servidor do arquivo pode estar fora do ar. appimage.error.uninstall_current_version=It was not possible to uninstall the current version of {} appimage.history.0_version=versão appimage.history.1_published_at=data @@ -29,7 +30,6 @@ appimage.info.symlink=Link simbólico appimage.info.url_download=URL do arquivo appimage.install.appimagelauncher.error={appimgl} não está permitindo que o {app} seja instalado. Desinstale o {appimgl}, reinicie o sistema e tente instalar o {app} novamente. appimage.install.desktop_entry=Criando um atalho no menu -appimage.install.download.error=Não foi possível baixar o arquivo {}. O servidor do arquivo pode estar fora do ar. appimage.install.extract=Extraindo o conteúdo de {} appimage.install.imported.rename_error=Não foi possível mover o arquivo {} para {} appimage.install.permission=Concedendo permissão de execução para {} diff --git a/bauh/gems/appimage/resources/locale/ru b/bauh/gems/appimage/resources/locale/ru index 4f4913ee..473e5918 100644 --- a/bauh/gems/appimage/resources/locale/ru +++ b/bauh/gems/appimage/resources/locale/ru @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} Имеет только одну опуб appimage.downgrade.impossible.title=Не удалось понизить версию appimage.downgrade.install_version=Не удалось установить версию {} ({}) appimage.downgrade.unknown_version.body=Не удалось определить текущую версию {} в истории версий +appimage.download.error=Не удалось загрузить файл {}. Файловый сервер не отвечает appimage.error.uninstall_current_version=Не удалось удалить текущую версию {} appimage.history.0_version=версия appimage.history.1_published_at=дата @@ -29,7 +30,6 @@ appimage.info.symlink=Symlink appimage.info.url_download=URL Файла appimage.install.appimagelauncher.error={appimgl} не позволяет установить {app} . Удалите {appimgl}, перезагрузите ваш компьютер и попробуйте снова установить {app} . appimage.install.desktop_entry=Создать ярлык в меню -appimage.install.download.error=Не удалось загрузить файл {}. Файловый сервер не отвечает appimage.install.extract=Извлечь содержимое из {} appimage.install.imported.rename_error=Не удалось переместить файл {} в {} appimage.install.permission=Установить права на выполнение для {} diff --git a/bauh/gems/appimage/resources/locale/tr b/bauh/gems/appimage/resources/locale/tr index bca9a45d..cebcd809 100644 --- a/bauh/gems/appimage/resources/locale/tr +++ b/bauh/gems/appimage/resources/locale/tr @@ -17,6 +17,7 @@ appimage.downgrade.impossible.body={} yalnızca bir yayınlanmış sürümüne s appimage.downgrade.impossible.title=Sürüm düşürmek imkansız appimage.downgrade.install_version={} ({}) sürümünü kurmak mümkün değildi appimage.downgrade.unknown_version.body=Sürüm geçmişinde {} mevcut sürümü tanımlamak mümkün değildi +appimage.download.error={} dosyası indirilemedi. Dosya sunucusu kapalı olabilir. appimage.error.uninstall_current_version={} mevcut sürümünü kaldırmak mümkün değildi appimage.history.0_version=sürüm appimage.history.1_published_at=tarih @@ -29,7 +30,6 @@ appimage.info.symlink=Symlink appimage.info.url_download=Dosya Bağlantısı appimage.install.appimagelauncher.error={appimgl}, {app} uygulamasının yüklenmesine izin vermiyor. {appimgl} yazılımını kaldırın, sisteminizi yeniden başlatın ve {app} yazılımını tekrar yüklemeyi deneyin. appimage.install.desktop_entry=Bir menü kısayolu oluşturuluyor -appimage.install.download.error={} dosyası indirilemedi. Dosya sunucusu kapalı olabilir. appimage.install.extract={} 'den içerik ayıklanıyor appimage.install.imported.rename_error={} dosyasını {} klasörüne taşımak mümkün değildi appimage.install.permission={} için yürütme izni veriliyor From 6a68588cd4cb7fedf73138853f86e8fca9e861fd Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 19 Nov 2021 18:21:25 -0300 Subject: [PATCH 18/26] [appimage] improvement: not stopping the upgrade process when one of several applications have been selected to upgrade --- CHANGELOG.md | 4 +++- bauh/gems/appimage/controller.py | 25 ++++++++++++++++++------- bauh/gems/appimage/resources/locale/ca | 1 + bauh/gems/appimage/resources/locale/de | 1 + bauh/gems/appimage/resources/locale/en | 1 + bauh/gems/appimage/resources/locale/es | 1 + bauh/gems/appimage/resources/locale/fr | 1 + bauh/gems/appimage/resources/locale/it | 1 + bauh/gems/appimage/resources/locale/pt | 1 + bauh/gems/appimage/resources/locale/ru | 1 + bauh/gems/appimage/resources/locale/tr | 1 + 11 files changed, 30 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36dfd201..f839ce08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - displaying initial warnings related to supported technologies even when they are not enabled or have the required dependencies - crashing when QT components sizes are not integers [#198](https://github.com/vinifmor/bauh/issues/198) - +### Improvements +- AppImage + - not stopping the upgrade process when one of several applications have been selected to upgrade ## [0.9.20] 2021-11-05 ### Improvements diff --git a/bauh/gems/appimage/controller.py b/bauh/gems/appimage/controller.py index d674e3c7..5cc6d44f 100644 --- a/bauh/gems/appimage/controller.py +++ b/bauh/gems/appimage/controller.py @@ -359,29 +359,40 @@ def downgrade(self, pkg: AppImage, root_password: str, watcher: ProcessWatcher) return False def upgrade(self, requirements: UpgradeRequirements, root_password: str, watcher: ProcessWatcher) -> bool: + not_upgraded = [] + for req in requirements.to_upgrade: watcher.change_status("{} {} ({})...".format(self.i18n['manage_window.status.upgrading'], req.pkg.name, req.pkg.version)) download_data = self._download(req.pkg, watcher) if not download_data: - return False + not_upgraded.append(req.pkg) + watcher.change_substatus('') + continue if not self.uninstall(req.pkg, root_password, watcher).success: - watcher.show_message(title=self.i18n['error'], - body=self.i18n['appimage.error.uninstall_current_version'], - type_=MessageType.ERROR) + not_upgraded.append(req.pkg) watcher.change_substatus('') - return False + continue if not self._install(pkg=req.pkg, watcher=watcher, pre_downloaded_file=download_data).success: + not_upgraded.append(req.pkg) watcher.change_substatus('') - return False + continue self.cache_to_disk(req.pkg, None, False) + all_failed = len(not_upgraded) == len(requirements.to_upgrade) + + if not_upgraded: + pkgs_str = ''.join((f'
  • {app.name}
  • ' for app in not_upgraded)) + watcher.show_message(title=self.i18n['error' if all_failed else 'warning'].capitalize(), + body=self.i18n['appimage.upgrade.failed'].format(apps=f'
      {pkgs_str}
    '), + type_=MessageType.ERROR if all_failed else MessageType.WARNING) + watcher.change_substatus('') - return True + return not all_failed def uninstall(self, pkg: AppImage, root_password: str, watcher: ProcessWatcher, disk_loader: DiskCacheLoader = None) -> TransactionResult: if os.path.exists(pkg.get_disk_cache_path()): diff --git a/bauh/gems/appimage/resources/locale/ca b/bauh/gems/appimage/resources/locale/ca index cb89108d..6e001ac4 100644 --- a/bauh/gems/appimage/resources/locale/ca +++ b/bauh/gems/appimage/resources/locale/ca @@ -36,6 +36,7 @@ appimage.install.permission=S’està concedint el permís d’execució a {} appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Actualització de bases de dades appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/de b/bauh/gems/appimage/resources/locale/de index f4b4659e..809b4e57 100644 --- a/bauh/gems/appimage/resources/locale/de +++ b/bauh/gems/appimage/resources/locale/de @@ -36,6 +36,7 @@ appimage.install.permission=Ausführberechtigungen für {} appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Updating databases appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/en b/bauh/gems/appimage/resources/locale/en index 2c8097b4..d30d5989 100644 --- a/bauh/gems/appimage/resources/locale/en +++ b/bauh/gems/appimage/resources/locale/en @@ -36,6 +36,7 @@ appimage.install.permission=Giving execution permission to {} appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Updating databases appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/es b/bauh/gems/appimage/resources/locale/es index 8232058f..344d3cae 100644 --- a/bauh/gems/appimage/resources/locale/es +++ b/bauh/gems/appimage/resources/locale/es @@ -36,6 +36,7 @@ appimage.install.permission=Concediendo permiso de ejecución a {} appimage.update_database.deleting_old=Eliminando archivos antiguos appimage.update_database.downloading=Descargando archivos de la base de datos appimage.update_database.uncompressing=Descomprindo archivos +appimage.upgrade.failed=No fue posible actualizar las siguientes aplicaciones: {apps} appimage.task.db_update=Actualizando base de datos appimage.task.db_update.checking=Buscando actualizaciones appimage.task.suggestions=Descargando sugerencias diff --git a/bauh/gems/appimage/resources/locale/fr b/bauh/gems/appimage/resources/locale/fr index 3fa93bf8..6c6699cf 100644 --- a/bauh/gems/appimage/resources/locale/fr +++ b/bauh/gems/appimage/resources/locale/fr @@ -35,6 +35,7 @@ appimage.install.permission={} est maintenant exécutable appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Mise à jour des bases de données appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/it b/bauh/gems/appimage/resources/locale/it index f7c4f3a5..9b9330ce 100644 --- a/bauh/gems/appimage/resources/locale/it +++ b/bauh/gems/appimage/resources/locale/it @@ -36,6 +36,7 @@ appimage.install.permission=Gdare il permesso di esecuzione a {} appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Aggiornamento dei database appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/pt b/bauh/gems/appimage/resources/locale/pt index 0575edd9..51e1dd98 100644 --- a/bauh/gems/appimage/resources/locale/pt +++ b/bauh/gems/appimage/resources/locale/pt @@ -36,6 +36,7 @@ appimage.install.permission=Concedendo permissão de execução para {} appimage.update_database.deleting_old=Removendo arquicos antigos appimage.update_database.downloading=Baixando arquivos do banco de dados appimage.update_database.uncompressing=Descomprimindo arquivos +appimage.upgrade.failed=Não foi possível atualizar as seguintes aplicações: {apps} appimage.task.db_update=Atualizando base de dados appimage.task.db_update.checking=Checando atualizações appimage.task.suggestions=Baixando sugestões diff --git a/bauh/gems/appimage/resources/locale/ru b/bauh/gems/appimage/resources/locale/ru index 473e5918..f5d2ff1a 100644 --- a/bauh/gems/appimage/resources/locale/ru +++ b/bauh/gems/appimage/resources/locale/ru @@ -36,6 +36,7 @@ appimage.install.permission=Установить права на выполне appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Обновление базы данных appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions diff --git a/bauh/gems/appimage/resources/locale/tr b/bauh/gems/appimage/resources/locale/tr index cebcd809..2c0f79e6 100644 --- a/bauh/gems/appimage/resources/locale/tr +++ b/bauh/gems/appimage/resources/locale/tr @@ -36,6 +36,7 @@ appimage.install.permission={} için yürütme izni veriliyor appimage.update_database.deleting_old=Removing old files appimage.update_database.downloading=Downloading database files appimage.update_database.uncompressing=Uncompressing files +appimage.upgrade.failed=It was not possible to upgrade the following applications: {apps} appimage.task.db_update=Veritabanları güncelleniyor appimage.task.db_update.checking=Checking for updates appimage.task.suggestions=Downloading suggestions From a136ef28f45ed343ed88770f2a4283fe58eea4ae Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 19 Nov 2021 18:28:35 -0300 Subject: [PATCH 19/26] [core] improvement: multi-threaded download not enabled by default since it fails for some scenarios --- CHANGELOG.md | 3 +++ bauh/view/core/config.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f839ce08..663fb2fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - crashing when QT components sizes are not integers [#198](https://github.com/vinifmor/bauh/issues/198) ### Improvements +- General + - multi-threaded download not enabled by default since it fails for some scenarios (still can be enabled through the settings panel/file) + - AppImage - not stopping the upgrade process when one of several applications have been selected to upgrade diff --git a/bauh/view/core/config.py b/bauh/view/core/config.py index 9737bc5c..850eca3a 100644 --- a/bauh/view/core/config.py +++ b/bauh/view/core/config.py @@ -48,7 +48,7 @@ def get_default_config(self) -> dict: }, 'download': { - 'multithreaded': True, + 'multithreaded': False, 'multithreaded_client': None, 'icons': True }, From aef9ef0b0dfbf4e914299ea7bf4fa0890af29bda Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 10:35:37 -0300 Subject: [PATCH 20/26] [core.downloader] refactoring: String concatenation using StringIO --- CHANGELOG.md | 3 ++- bauh/view/core/downloader.py | 29 ++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 663fb2fb..34b56276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,7 +27,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Improvements - General - multi-threaded download not enabled by default since it fails for some scenarios (still can be enabled through the settings panel/file) - + - refactorings related to String concatenation + - AppImage - not stopping the upgrade process when one of several applications have been selected to upgrade diff --git a/bauh/view/core/downloader.py b/bauh/view/core/downloader.py index 07df914d..92f0ffad 100644 --- a/bauh/view/core/downloader.py +++ b/bauh/view/core/downloader.py @@ -4,6 +4,7 @@ import shutil import time import traceback +from io import StringIO from math import floor from threading import Thread from typing import Iterable, List @@ -12,7 +13,7 @@ from bauh.api.abstract.handler import ProcessWatcher from bauh.api.http import HttpClient from bauh.commons.html import bold -from bauh.commons.system import run_cmd, ProcessHandler, SimpleProcess, get_human_size_str +from bauh.commons.system import ProcessHandler, SimpleProcess, get_human_size_str from bauh.view.util.translation import I18n RE_HAS_EXTENSION = re.compile(r'.+\.\w+$') @@ -94,12 +95,15 @@ def _rm_bad_file(self, file_name: str, output_path: str, cwd, handler: ProcessHa success, _ = handler.handle_simple(SimpleProcess(['rm', '-rf',to_delete], root_password=root_password)) return success - def _display_file_size(self, file_url: str, base_substatus, watcher: ProcessWatcher): + def _concat_file_size(self, file_url: str, base_substatus: StringIO, watcher: ProcessWatcher): + watcher.change_substatus(f'{base_substatus.getvalue()} ( ? Mb )') + try: size = self.http_client.get_content_length(file_url) if size: - watcher.change_substatus(base_substatus + ' ( {} )'.format(size)) + base_substatus.write(f' ( {size} )') + watcher.change_substatus(base_substatus.getvalue()) except: pass @@ -153,21 +157,20 @@ def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = No if output_path and not RE_HAS_EXTENSION.match(name) and RE_HAS_EXTENSION.match(output_path): name = output_path.split('/')[-1] - if substatus_prefix: - msg = substatus_prefix + ' ' - else: - msg = '' - - msg += bold('[{}] ').format(downloader) + self.i18n['downloading'] + ' ' + bold(name) - if watcher: - watcher.change_substatus(msg) + msg = StringIO() + msg.write(f'{substatus_prefix} ' if substatus_prefix else '') + msg.write(f"{bold('[{}]'.format(downloader))} {self.i18n['downloading']} {bold(name)}") if display_file_size: if known_size: - watcher.change_substatus(msg + ' ( {} )'.format(get_human_size_str(known_size))) + msg.write(f' ( {get_human_size_str(known_size)} )') + watcher.change_substatus(msg.getvalue()) else: - Thread(target=self._display_file_size, args=(file_url, msg, watcher)).start() + Thread(target=self._concat_file_size, args=(file_url, msg, watcher)).start() + else: + msg.write(' ( ? Mb )') + watcher.change_substatus(msg.getvalue()) success, _ = handler.handle_simple(process) except: From 0c4b479de9096e988ceb0bbda704fc045b4c71a8 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 10:37:11 -0300 Subject: [PATCH 21/26] [api.http] refactoring: removing unneeded return type --- bauh/api/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/api/http.py b/bauh/api/http.py index cc54d9d3..20b9a84d 100644 --- a/bauh/api/http.py +++ b/bauh/api/http.py @@ -70,7 +70,7 @@ def get_yaml(self, url: str, params: dict = None, headers: dict = None, allow_re def get_content_length_in_bytes(self, url: str, session: bool = True) -> Optional[int]: if not url: - return None + return params = {'url': url, 'allow_redirects': True, 'stream': True} From 11af3c0bbc33890d87e2bef1b8a797e2b3fb5df2 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 10:44:25 -0300 Subject: [PATCH 22/26] [view.core.downloader] refactoring: changing String formatting method --- bauh/view/core/downloader.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bauh/view/core/downloader.py b/bauh/view/core/downloader.py index 92f0ffad..a53f7718 100644 --- a/bauh/view/core/downloader.py +++ b/bauh/view/core/downloader.py @@ -74,7 +74,7 @@ def _get_axel_process(self, url: str, output_path: str, cwd: str, root_password: cmd = ['axel', url, '-n', str(threads), '-4', '-c', '-T', '5'] if output_path: - cmd.append('--output={}'.format(output_path)) + cmd.append(f'--output={output_path}') return SimpleProcess(cmd=cmd, cwd=cwd, root_password=root_password) @@ -88,16 +88,16 @@ def _get_wget_process(self, url: str, output_path: str, cwd: str, root_password: return SimpleProcess(cmd=cmd, cwd=cwd, root_password=root_password) def _rm_bad_file(self, file_name: str, output_path: str, cwd, handler: ProcessHandler, root_password: str): - to_delete = output_path if output_path else '{}/{}'.format(cwd, file_name) + to_delete = output_path if output_path else f'{cwd}/{file_name}' if to_delete and os.path.exists(to_delete): - self.logger.info('Removing downloaded file {}'.format(to_delete)) - success, _ = handler.handle_simple(SimpleProcess(['rm', '-rf',to_delete], root_password=root_password)) + self.logger.info(f'Removing downloaded file {to_delete}') + success, _ = handler.handle_simple(SimpleProcess(['rm', '-rf', to_delete], root_password=root_password)) return success def _concat_file_size(self, file_url: str, base_substatus: StringIO, watcher: ProcessWatcher): watcher.change_substatus(f'{base_substatus.getvalue()} ( ? Mb )') - + try: size = self.http_client.get_content_length(file_url) @@ -121,7 +121,7 @@ def _get_appropriate_threads_number(self, max_threads: int, known_size: int) -> return threads def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = None, cwd: str = None, root_password: str = None, substatus_prefix: str = None, display_file_size: bool = True, max_threads: int = None, known_size: int = None) -> bool: - self.logger.info('Downloading {}'.format(file_url)) + self.logger.info(f'Downloading {file_url}') handler = ProcessHandler(watcher) file_name = file_url.split('/')[-1] @@ -131,9 +131,9 @@ def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = No ti = time.time() try: if output_path and os.path.exists(output_path): - self.logger.info('Removing old file found before downloading: {}'.format(output_path)) + self.logger.info(f'Removing old file found before downloading: {output_path}') os.remove(output_path) - self.logger.info("Old file {} removed".format(output_path)) + self.logger.info(f'Old file {output_path} removed') client = self.get_available_multithreaded_tool() if client: @@ -178,10 +178,10 @@ def download(self, file_url: str, watcher: ProcessWatcher, output_path: str = No self._rm_bad_file(file_name, output_path, final_cwd, handler, root_password) tf = time.time() - self.logger.info(file_name + ' download took {0:.2f} minutes'.format((tf - ti) / 60)) + self.logger.info(f'{file_name} download took {(tf - ti) / 60:.2f} minutes') if not success: - self.logger.error("Could not download '{}'".format(file_name)) + self.logger.error(f"Could not download '{file_name}'") self._rm_bad_file(file_name, output_path, final_cwd, handler, root_password) return success From 84518ce34d336abf719cbba30bf8fdde40e538da Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 10:51:50 -0300 Subject: [PATCH 23/26] [view.core.controller] fix: install/uninstall logs --- bauh/view/core/controller.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index 16a74eb9..4617718f 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -327,7 +327,7 @@ def uninstall(self, pkg: SoftwarePackage, root_password: str, handler: ProcessWa return TransactionResult(success=False, installed=[], removed=[]) finally: tf = time.time() - self.logger.info('Uninstallation of {}'.format(pkg) + 'took {0:.2f} minutes'.format((tf - ti) / 60)) + self.logger.info(f'Uninstallation of {pkg} took {(tf - ti) / 60:.2f} minutes') def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCacheLoader, handler: ProcessWatcher) -> TransactionResult: man = self._get_manager_for(app) @@ -348,7 +348,7 @@ def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCac return TransactionResult(success=False, installed=[], removed=[]) finally: tf = time.time() - self.logger.info('Installation of {}'.format(app) + 'took {0:.2f} minutes'.format((tf - ti)/60)) + self.logger.info(f'Installation of {app} took {(tf - ti) / 60:.2f} minutes') def get_info(self, app: SoftwarePackage): man = self._get_manager_for(app) From 1cd060cd1f46c04f3167cd4196ac8e80b173f639 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 10:52:44 -0300 Subject: [PATCH 24/26] [view.core.controller] refactoring: removing duplicate import --- bauh/view/core/controller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index 4617718f..acd117c1 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -1,5 +1,4 @@ import re -import re import shutil import time import traceback From 971e9a58c742188c163614789051012399161eae Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 11:18:09 -0300 Subject: [PATCH 25/26] [view.core.controller] refactoring: changing String formatting method --- bauh/view/core/controller.py | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/bauh/view/core/controller.py b/bauh/view/core/controller.py index acd117c1..70a94a87 100755 --- a/bauh/view/core/controller.py +++ b/bauh/view/core/controller.py @@ -148,7 +148,7 @@ def _search(self, word: str, is_url: bool, man: SoftwareManager, disk_loader, re mti = time.time() apps_found = man.search(words=word, disk_loader=disk_loader, is_url=is_url) mtf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.8f} seconds".format(mtf - mti)) + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.8f} seconds') res.installed.extend(apps_found.installed) res.new.extend(apps_found.new) @@ -187,7 +187,7 @@ def search(self, words: str, disk_loader: DiskCacheLoader = None, limit: int = - res.update_total() tf = time.time() - self.logger.info('Took {0:.8f} seconds'.format(tf - ti)) + self.logger.info(f'Took {tf - ti:.8f} seconds') return res def _wait_to_be_ready(self): @@ -223,7 +223,7 @@ def read_installed(self, disk_loader: DiskCacheLoader = None, limit: int = -1, o mti = time.time() man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=net_available) mtf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti)) + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.2f} seconds') res.installed.extend(man_res.installed) res.total += man_res.total @@ -241,7 +241,7 @@ def read_installed(self, disk_loader: DiskCacheLoader = None, limit: int = -1, o mti = time.time() man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=net_available) mtf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti)) + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.2f} seconds') res.installed.extend(man_res.installed) res.total += man_res.total @@ -261,7 +261,7 @@ def read_installed(self, disk_loader: DiskCacheLoader = None, limit: int = -1, o res.installed.sort(key=self._get_package_lower_name) tf = time.time() - self.logger.info('Took {0:.2f} seconds'.format(tf - ti)) + self.logger.info(f'Took {tf - ti:.2f} seconds') return res def downgrade(self, app: SoftwarePackage, root_password: str, handler: ProcessWatcher) -> bool: @@ -271,10 +271,10 @@ def downgrade(self, app: SoftwarePackage, root_password: str, handler: ProcessWa mti = time.time() res = man.downgrade(app, root_password, handler) mtf = time.time() - self.logger.info('Took {0:.2f} seconds'.format(mtf - mti)) + self.logger.info(f'Took {mtf - mti:.2f} seconds') return res else: - raise Exception("downgrade is not possible for {}".format(app.__class__.__name__)) + raise Exception(f"Downgrading is not possible for {app.__class__.__name__}") def clean_cache_for(self, app: SoftwarePackage): man = self._get_manager_for(app) @@ -314,7 +314,7 @@ def uninstall(self, pkg: SoftwarePackage, root_password: str, handler: ProcessWa ti = time.time() disk_loader = self.disk_loader_factory.new() disk_loader.start() - self.logger.info("Uninstalling {}".format(pkg.name)) + self.logger.info(f"Uninstalling {pkg.name}") try: res = man.uninstall(pkg, root_password, handler, disk_loader) disk_loader.stop_working() @@ -336,7 +336,7 @@ def install(self, app: SoftwarePackage, root_password: str, disk_loader: DiskCac disk_loader = self.disk_loader_factory.new() disk_loader.start() try: - self.logger.info('Installing {}'.format(app)) + self.logger.info(f'Installing {app}') res = man.install(app, root_password, disk_loader, handler) disk_loader.stop_working() disk_loader.join() @@ -362,7 +362,7 @@ def get_history(self, app: SoftwarePackage) -> PackageHistory: mti = time.time() history = man.get_history(app) mtf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti)) + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.2f} seconds') return history def get_managed_types(self) -> Set[Type[SoftwarePackage]]: @@ -424,7 +424,7 @@ def prepare(self, task_manager: TaskManager, root_password: str, internet_availa t.join() tf = time.time() - self.logger.info("Finished. Took {0:.2f} seconds".format(tf - ti)) + self.logger.info(f'Finished ({tf - ti:.2f} seconds)') def cache_available_managers(self): if self.managers: @@ -473,7 +473,7 @@ def _fill_suggestions(self, suggestions: list, man: SoftwareManager, limit: int, mti = time.time() man_sugs = man.list_suggestions(limit=limit, filter_installed=filter_installed) mtf = time.time() - self.logger.info(man.__class__.__name__ + ' took {0:.5f} seconds'.format(mtf - mti)) + self.logger.info(f'{man.__class__.__name__} took {mtf - mti:.5f} seconds') if man_sugs: if 0 < limit < len(man_sugs): @@ -506,7 +506,7 @@ def execute_custom_action(self, action: CustomSoftwareAction, pkg: SoftwarePacka man = action.manager if action.manager else self._get_manager_for(pkg) if man: - return eval('man.{}({}root_password=root_password, watcher=watcher)'.format(action.manager_method, 'pkg=pkg, ' if pkg else '')) + return eval(f"man.{action.manager_method}({'pkg=pkg, ' if pkg else ''}root_password=root_password, watcher=watcher)") def is_default_enabled(self) -> bool: return True @@ -517,7 +517,7 @@ def launch(self, pkg: SoftwarePackage): man = self._get_manager_for(pkg) if man: - self.logger.info('Launching {}'.format(pkg)) + self.logger.info(f'Launching {pkg}') man.launch(pkg) def get_screenshots(self, pkg: SoftwarePackage): @@ -574,7 +574,7 @@ def get_upgrade_requirements(self, pkgs: List[SoftwarePackage], root_password: s ti = time.time() man_reqs = man.get_upgrade_requirements(pkgs, root_password, watcher) tf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(tf - ti)) + self.logger.info(f'{man.__class__.__name__} took {tf - ti:.2f} seconds') if not man_reqs: return # it means the process should be stopped @@ -596,8 +596,9 @@ def get_upgrade_requirements(self, pkgs: List[SoftwarePackage], root_password: s return res def reset(self, root_password: str, watcher: ProcessWatcher) -> bool: - body = '

    {}

    {}

    '.format(self.i18n['action.reset.body_1'].format(bold(self.context.app_name)), - self.i18n['action.reset.body_2']) + body = f"

    {self.i18n['action.reset.body_1'].format(bold(self.context.app_name))}

    " \ + f"

    {self.i18n['action.reset.body_2']}

    " + if watcher.request_confirmation(title=self.i18n['action.reset'], body=body, confirmation_label=self.i18n['proceed'].capitalize(), @@ -643,7 +644,7 @@ def _fill_sizes(self, man: SoftwareManager, pkgs: List[SoftwarePackage]): ti = time.time() man.fill_sizes(pkgs) tf = time.time() - self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(tf - ti)) + self.logger.info(f'{man.__class__.__name__} took {tf - ti:.2f} seconds') def fill_sizes(self, pkgs: List[SoftwarePackage]): by_manager = self._map_pkgs_by_manager(pkgs, pkg_filters=[lambda p: p.size is None]) From 2cc532f6d106dd4c9d2adb334a2d2142f1d55edb Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Sat, 20 Nov 2021 11:18:57 -0300 Subject: [PATCH 26/26] [CHANGELOG.md] adding release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34b56276..08942300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). -## [0.9.21] 2021 +## [0.9.21] 2021-11-20 ### Fixes - General - more fixes related to some backend commands hanging