diff --git a/CHANGELOG.md b/CHANGELOG.md index b1965a55..6baf20ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,24 @@ 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.8.4] - 2020-02-21 +### Improvements +- UI + - treating multiple lines on the application's description displayed on the table +- AUR + - generating the semantic search map on demand instead of storing it in memory +- Russian translations by: + - [leoneii](https://github.com/leoneii) - PRs: [#61](https://github.com/vinifmor/bauh/pull/61) [#63](https://github.com/vinifmor/bauh/pull/63) + - [mountain-biker85](https://github.com/mountain-biker85) - PRs: [#62](https://github.com/vinifmor/bauh/pull/62) [#64](https://github.com/vinifmor/bauh/pull/64) +### Fixes +- Snap + - not able to launch applications on some distros ( e.g: OpenSuse ) [#58](https://github.com/vinifmor/bauh/issues/58) +- AUR + - package name tooltip was displaying only the repository ( table row ) +- UI + - not displaying some priority search results at the top of the table + ## [0.8.3] - 2020-02-13 ### Improvements @@ -15,7 +33,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - checking architecture dependencies (x86_64, i686) - architecture dependencies are displayed on the info window as well - optimizations to speed up zst packages building - - showing a warning messaging when trying to install / update / downgrade a package with the root user + - showing a warning message when trying to install / update / downgrade a package with the root user - UI: - **Settings** available as a tray action as well - minor improvements diff --git a/bauh/__init__.py b/bauh/__init__.py index a504cd73..8ffa3003 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.8.3' +__version__ = '0.8.4' __app_name__ = 'bauh' import os diff --git a/bauh/gems/arch/controller.py b/bauh/gems/arch/controller.py index 3d8d34ee..d2d25124 100644 --- a/bauh/gems/arch/controller.py +++ b/bauh/gems/arch/controller.py @@ -47,12 +47,6 @@ SOURCE_FIELDS = ('source', 'source_x86_64') RE_PRE_DOWNLOAD_WL_PROTOCOLS = re.compile(r'^(.+::)?(https?|ftp)://.+') RE_PRE_DOWNLOAD_BL_EXT = re.compile(r'.+\.(git|gpg)$') -SEARCH_OPTIMIZED_MAP = { - 'google chrome': 'google-chrome', - 'chrome google': 'google-chrome', - 'googlechrome': 'google-chrome' -} - class ArchManager(SoftwareManager): @@ -75,6 +69,11 @@ class ArchManager(SoftwareManager): self.local_config = None self.http_client = context.http_client + def get_semantic_search_map(self) -> Dict[str, str]: + return {'google chrome': 'google-chrome', + 'chrome google': 'google-chrome', + 'googlechrome': 'google-chrome'} + def _upgrade_search_result(self, apidata: dict, installed_pkgs: dict, downgrade_enabled: bool, res: SearchResult, disk_loader: DiskCacheLoader): app = self.mapper.map_api_data(apidata, installed_pkgs['not_signed'], self.categories) app.downgrade_enabled = downgrade_enabled @@ -100,7 +99,7 @@ class ArchManager(SoftwareManager): read_installed = Thread(target=lambda: installed.update(pacman.list_and_map_installed()), daemon=True) read_installed.start() - mapped_words = SEARCH_OPTIMIZED_MAP.get(words) + mapped_words = self.get_semantic_search_map().get(words) api_res = self.aur_client.search(mapped_words if mapped_words else words) diff --git a/bauh/gems/arch/model.py b/bauh/gems/arch/model.py index 437b34b3..37d3a3b7 100644 --- a/bauh/gems/arch/model.py +++ b/bauh/gems/arch/model.py @@ -125,7 +125,7 @@ class ArchPackage(SoftwarePackage): return False def get_name_tooltip(self) -> str: - return '{}: {}'.format(self.i18n['repository'], self.mirror) + return '{} ( {}: {} )'.format(self.name, self.i18n['repository'], self.mirror) def __str__(self): return self.__repr__() diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index bcf2cef2..0f0972b1 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -36,6 +36,13 @@ class SnapManager(SoftwareManager): self.categories_downloader = CategoriesDownloader('snap', self.http_client, self.logger, self, context.disk_cache, URL_CATEGORIES_FILE, SNAP_CACHE_PATH, CATEGORIES_FILE_PATH) self.suggestions_cache = context.cache_factory.new() + self.info_path = None + + def get_info_path(self) -> str: + if self.info_path is None: + self.info_path = snap.get_app_info_path() + + return self.info_path def map_json(self, app_json: dict, installed: bool, disk_loader: DiskCacheLoader, internet: bool = True) -> SnapApplication: app = SnapApplication(publisher=app_json.get('publisher'), @@ -112,9 +119,11 @@ class SnapManager(SoftwareManager): return SearchResult([], [], 0) def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None) -> SearchResult: - if snap.is_snapd_running(): + info_path = self.get_info_path() + + if snap.is_snapd_running() and info_path: self.categories_downloader.join() - installed = [self.map_json(app_json, installed=True, disk_loader=disk_loader, internet=internet_available) for app_json in snap.read_installed(self.ubuntu_distro)] + installed = [self.map_json(app_json, installed=True, disk_loader=disk_loader, internet=internet_available) for app_json in snap.read_installed(info_path)] return SearchResult(installed, None, len(installed)) else: return SearchResult([], None, 0) @@ -159,6 +168,11 @@ class SnapManager(SoftwareManager): raise Exception("'get_history' is not supported by {}".format(pkg.__class__.__name__)) def install(self, pkg: SnapApplication, root_password: str, watcher: ProcessWatcher) -> bool: + info_path = self.get_info_path() + + if not info_path: + self.logger.warning('Information directory was not found. It will not be possible to determine if the installed application can be launched') + res, output = ProcessHandler(watcher).handle_simple(snap.install_and_stream(pkg.name, pkg.confinement, root_password)) if 'error:' in output: @@ -180,14 +194,15 @@ class SnapManager(SoftwareManager): self.logger.info("Installing '{}' with the custom command '{}'".format(pkg.name, channel_select.value)) res = ProcessHandler(watcher).handle(SystemProcess(new_root_subprocess(channel_select.value.value.split(' '), root_password=root_password))) - if res: - pkg.has_apps_field = snap.has_apps_field(pkg.name, self.ubuntu_distro) + if res and info_path: + pkg.has_apps_field = snap.has_apps_field(pkg.name, info_path) return res else: self.logger.error("Could not find available channels in the installation output: {}".format(output)) else: - pkg.has_apps_field = snap.has_apps_field(pkg.name, self.ubuntu_distro) + if info_path: + pkg.has_apps_field = snap.has_apps_field(pkg.name, info_path) return res diff --git a/bauh/gems/snap/snap.py b/bauh/gems/snap/snap.py index badace69..27f5f56f 100644 --- a/bauh/gems/snap/snap.py +++ b/bauh/gems/snap/snap.py @@ -1,4 +1,5 @@ import logging +import os import re import subprocess from io import StringIO @@ -85,7 +86,7 @@ def get_info(app_name: str, attrs: tuple = None): return data -def read_installed(ubuntu_distro: bool) -> List[dict]: +def read_installed(info_path: str) -> List[dict]: res = run_cmd('{} list'.format(BASE_CMD), print_error=False) apps = [] @@ -98,8 +99,6 @@ def read_installed(ubuntu_distro: bool) -> List[dict]: if idx > 0 and app_str: apps.append(app_str_to_json(app_str)) - info_path = _get_app_info_path(ubuntu_distro) - info_out = new_subprocess(['cat', *[info_path.format(a['name']) for a in apps]]).stdout idx = -1 @@ -116,16 +115,16 @@ def read_installed(ubuntu_distro: bool) -> List[dict]: return apps -def _get_app_info_path(ubuntu_distro: bool) -> str: - if ubuntu_distro: +def get_app_info_path() -> str: + if os.path.exists('/snap'): return '/snap/{}/current/meta/snap.yaml' - else: + elif os.path.exists('/var/lib/snapd/snap'): return '/var/lib/snapd/snap/{}/current/meta/snap.yaml' + else: + return None -def has_apps_field(name: str, ubuntu_distro: bool) -> bool: - info_path = _get_app_info_path(ubuntu_distro) - +def has_apps_field(name: str, info_path: str) -> bool: info_out = new_subprocess(['cat', info_path.format(name)]).stdout res = False diff --git a/bauh/view/qt/apps_table.py b/bauh/view/qt/apps_table.py index b14b53f9..60bbcaa8 100644 --- a/bauh/view/qt/apps_table.py +++ b/bauh/view/qt/apps_table.py @@ -381,7 +381,7 @@ class AppsTable(QTableWidget): item.setMinimumWidth(300) if pkg.model.description is not None or not pkg.model.is_application() or pkg.model.status == PackageStatus.READY: - desc = pkg.model.description + desc = pkg.model.description.split('\n')[0] if pkg.model.description else pkg.model.description else: desc = '...' diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 8c7ce9d3..05a7526a 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -694,7 +694,7 @@ class ManageWindow(QWidget): def _gen_filters(self, updates: int = 0, ignore_updates: bool = False) -> dict: return { - 'only_apps': self.filter_only_apps, + 'only_apps': False if self.search_performed else self.filter_only_apps, 'type': self.type_filter, 'category': self.category_filter, 'updates': False if ignore_updates else self.filter_updates, diff --git a/bauh/view/resources/locale/ca b/bauh/view/resources/locale/ca index 985c321c..2bba847e 100644 --- a/bauh/view/resources/locale/ca +++ b/bauh/view/resources/locale/ca @@ -266,6 +266,7 @@ locale.pt=portuguès locale.ca=català locale.de=alemany locale.it=italià +locale.ru=rus interval=interval installation=instal·lació download=download diff --git a/bauh/view/resources/locale/de b/bauh/view/resources/locale/de index 7f680872..bdb8814a 100644 --- a/bauh/view/resources/locale/de +++ b/bauh/view/resources/locale/de @@ -221,6 +221,7 @@ locale.pt=portugiesisch locale.ca=Katalanisch locale.de=deutsch locale.it=italienisch +locale.ru=russisch interval=intervall installation=Installation download=download diff --git a/bauh/view/resources/locale/en b/bauh/view/resources/locale/en index 12eb165f..57f05a51 100644 --- a/bauh/view/resources/locale/en +++ b/bauh/view/resources/locale/en @@ -228,6 +228,7 @@ locale.pt=portuguese locale.ca=catalan locale.de=german locale.it=italian +locale.ru=russian interval=interval installation=installation download=download diff --git a/bauh/view/resources/locale/es b/bauh/view/resources/locale/es index 6da1f891..526a4d56 100644 --- a/bauh/view/resources/locale/es +++ b/bauh/view/resources/locale/es @@ -269,6 +269,7 @@ locale.pt=portugués locale.ca=catalán locale.de=alemán locale.it=italiano +locale.ru=ruso interval=intervalo installation=instalación download=descarga diff --git a/bauh/view/resources/locale/it b/bauh/view/resources/locale/it index 3e8ecea2..4f8b104c 100644 --- a/bauh/view/resources/locale/it +++ b/bauh/view/resources/locale/it @@ -221,6 +221,7 @@ locale.pt=portoghese locale.ca=catalan locale.de=tedesco locale.it=italiano +locale.ru=russo interval=intervallo installation=installazione download=download diff --git a/bauh/view/resources/locale/pt b/bauh/view/resources/locale/pt index 513faf69..eb84e839 100644 --- a/bauh/view/resources/locale/pt +++ b/bauh/view/resources/locale/pt @@ -272,6 +272,7 @@ locale.pt=português locale.ca=catalão locale.de=alemão locale.it=italiano +locale.ru=russo interval=intervalo installation=instalação download=download diff --git a/bauh/view/util/translation.py b/bauh/view/util/translation.py index 0074a2b6..b3d0da13 100644 --- a/bauh/view/util/translation.py +++ b/bauh/view/util/translation.py @@ -75,7 +75,10 @@ def get_locale_keys(key: str = None, locale_dir: str = resource.get_path('locale for line in locale_keys: line_strip = line.strip() if line_strip: - keyval = line_strip.split('=') - locale_obj[keyval[0].strip()] = keyval[1].strip() + try: + keyval = line_strip.split('=') + locale_obj[keyval[0].strip()] = keyval[1].strip() + except: + print("Error decoding i18n line '{}'".format(line)) return locale_path.split('/')[-1], locale_obj