From 9aa069f4be6f8f2ce17ad0e05782c67018c0b44a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 12:07:50 -0300 Subject: [PATCH 1/8] fix suggestions error | improving warnings presentation | snapd health check when snapd.service is available --- CHANGELOG.md | 10 ++++++++- bauh/gems/snap/controller.py | 35 ++++++++++++++++-------------- bauh/gems/snap/resources/locale/en | 3 ++- bauh/gems/snap/resources/locale/es | 3 ++- bauh/gems/snap/resources/locale/pt | 3 ++- bauh/gems/snap/snap.py | 20 ++++++++++++++--- bauh/view/qt/thread.py | 2 +- bauh/view/qt/window.py | 2 +- 8 files changed, 53 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5845d960..270f610f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ 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.6.1] +### Improvements: +- Better warning presentation when there are several messages + +### Fixes: +- Error when retrieving suggestions +- snapd health check when snapd.service is available + ## [0.6.0] 2019-09-25 ### Features @@ -33,7 +41,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Environment variable / parameter **BAUH_UPDATE_NOTIFICATION** renamed to **BAUH_SYSTEM_NOTIFICATIONS** and now works for any system notification - Environment variable / parameter **BAUH_DOWNLOAD_MULTITHREAD**: if source files should be downloaded using multi-threads (not supported by all **gems**). - Environment variables / parameter **BAUH_MAX_DISPLAYED**: controls the maximum number of displayed apps ( default to 50 ) -- Environment variables / parameter **BAUH_LOGS**: controls the maximum number of displayed apps ( default to 50 ) +- Environment variables / parameter **BAUH_LOGS**: activates console logging. - small UI improvements ### UI Changes diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index 70a11c8a..dba2decd 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -9,6 +9,7 @@ from bauh.api.abstract.handler import ProcessWatcher from bauh.api.abstract.model import SoftwarePackage, PackageHistory, PackageUpdate, PackageSuggestion, \ SuggestionPriority from bauh.commons import internet +from bauh.commons.html import bold from bauh.commons.system import SystemProcess, ProcessHandler from bauh.gems.snap import snap, suggestions from bauh.gems.snap.constants import SNAP_API_URL @@ -83,7 +84,6 @@ class SnapManager(SoftwareManager): 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(): - internet_available = internet.is_available(self.http_client, self.logger) installed = [self.map_json(app_json, installed=True, disk_loader=disk_loader, internet=internet_available) for app_json in snap.read_installed()] return SearchResult(installed, None, len(installed)) else: @@ -146,7 +146,9 @@ class SnapManager(SoftwareManager): def list_warnings(self) -> List[str]: if not snap.is_snapd_running(): - return [self.i18n['snap.notification.snapd_unavailable']] + 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(self.i18n['manage_window.settings.gems']))] def _fill_suggestion(self, pkg_name: str, priority: SuggestionPriority, out: List[PackageSuggestion]): res = self.http_client.get_json(SNAP_API_URL + '/search?q=package_name:{}'.format(pkg_name)) @@ -163,24 +165,25 @@ class SnapManager(SoftwareManager): def list_suggestions(self, limit: int) -> List[PackageSuggestion]: res = [] - sugs = [(i, p) for i, p in suggestions.ALL.items()] - sugs.sort(key=lambda t: t[1].value, reverse=True) + if snap.is_snapd_running(): + sugs = [(i, p) for i, p in suggestions.ALL.items()] + sugs.sort(key=lambda t: t[1].value, reverse=True) - threads = [] - for sug in sugs: + threads = [] + for sug in sugs: - if limit <= 0 or len(res) < limit: - t = Thread(target=self._fill_suggestion, args=(sug[0], sug[1], res)) - t.start() - threads.append(t) - time.sleep(0.001) # to avoid being blocked - else: - break + if limit <= 0 or len(res) < limit: + t = Thread(target=self._fill_suggestion, args=(sug[0], sug[1], res)) + t.start() + threads.append(t) + time.sleep(0.001) # to avoid being blocked + else: + break - for t in threads: - t.join() + for t in threads: + t.join() - res.sort(key=lambda s: s.priority.value, reverse=True) + res.sort(key=lambda s: s.priority.value, reverse=True) return res def is_default_enabled(self) -> bool: diff --git a/bauh/gems/snap/resources/locale/en b/bauh/gems/snap/resources/locale/en index f2994234..8d514136 100644 --- a/bauh/gems/snap/resources/locale/en +++ b/bauh/gems/snap/resources/locale/en @@ -1,3 +1,4 @@ -snap.notification.snapd_unavailable=snapd seems not to be installed or enabled. snap packages will not be available. +snap.notification.snapd_unavailable={} seems not to be installed or enabled. {} packages will not be available. +snap.notification.snap.disable=If you do not want to use Snap applications, uncheck {} in {} snap.action.refresh.status=Refreshing snap.action.refresh.label=Refresh \ No newline at end of file diff --git a/bauh/gems/snap/resources/locale/es b/bauh/gems/snap/resources/locale/es index 43f2c667..935d8dc2 100644 --- a/bauh/gems/snap/resources/locale/es +++ b/bauh/gems/snap/resources/locale/es @@ -7,6 +7,7 @@ snap.info.revision=revisión snap.info.tracking=tracking snap.info.installed=instalado snap.info.publisher=publicador -snap.notification.snapd_unavailable=snapd no parece estar instalado o habilitado. los paquetes snap estarán indisponibles. +snap.notification.snapd_unavailable={} no parece estar instalado o habilitado. los paquetes {} estarán indisponibles. +snap.notification.snap.disable=Si no desea usar aplicativos Snap, desmarque {} en {} snap.action.refresh.status=Actualizando snap.action.refresh.label=Actualizar \ No newline at end of file diff --git a/bauh/gems/snap/resources/locale/pt b/bauh/gems/snap/resources/locale/pt index 2e675732..000a5c90 100644 --- a/bauh/gems/snap/resources/locale/pt +++ b/bauh/gems/snap/resources/locale/pt @@ -7,6 +7,7 @@ snap.info.revision=revisão snap.info.tracking=tracking snap.info.installed=instalado snap.info.publisher=publicador -snap.notification.snapd_unavailable=snapd não parece estar instalado ou habilitado. os pacotes snap estarão indisponíveis. +snap.notification.snapd_unavailable={} não parece estar instalado ou habilitado. os pacotes {} estarão indisponíveis. +snap.notification.snap.disable=Se não deseja usar aplicativos Snap, desmarque {} em {} snap.action.refresh.status=Atualizando snap.action.refresh.label=Atualizar \ No newline at end of file diff --git a/bauh/gems/snap/snap.py b/bauh/gems/snap/snap.py index 02288aa0..04e20de2 100644 --- a/bauh/gems/snap/snap.py +++ b/bauh/gems/snap/snap.py @@ -7,6 +7,8 @@ from bauh.commons.system import new_root_subprocess, run_cmd, new_subprocess from bauh.gems.snap.model import SnapApplication BASE_CMD = 'snap' +RE_SNAPD_STATUS = re.compile('\s+') +SNAPD_RUNNING_STATUS = {'listening', 'running'} def is_installed(): @@ -17,12 +19,24 @@ def is_installed(): def is_snapd_running() -> bool: services = new_subprocess(['systemctl', 'list-units']) - for o in new_subprocess(['grep', '-oP', 'snapd.socket.+\K(listening|running)'], stdin=services.stdout).stdout: + service, service_running = False, False + socket, socket_running = False, False + for o in new_subprocess(['grep', '-Eo', 'snapd.+'], stdin=services.stdout).stdout: if o: line = o.decode().strip() - return bool(line) - return False + if line: + line_split = RE_SNAPD_STATUS.split(line) + running = line_split[3] in SNAPD_RUNNING_STATUS + + if line_split[0] == 'snapd.service': + service = True + service_running = running + elif line_split[0] == 'snapd.socket': + socket = True + socket_running = running + + return socket and socket_running and (not service or (service and service_running)) def app_str_to_json(app: str) -> dict: diff --git a/bauh/view/qt/thread.py b/bauh/view/qt/thread.py index 1595cd52..c631dc99 100644 --- a/bauh/view/qt/thread.py +++ b/bauh/view/qt/thread.py @@ -389,7 +389,7 @@ class FindSuggestions(AsyncAction): def run(self): sugs = self.man.list_suggestions(limit=-1) - self.notify_finished([s.package for s in sugs] if sugs is not None else []) + self.notify_finished({'pkgs_found': [s.package for s in sugs] if sugs is not None else [], 'error': None}) class ListWarnings(QThread): diff --git a/bauh/view/qt/window.py b/bauh/view/qt/window.py index 498acabf..05693f66 100755 --- a/bauh/view/qt/window.py +++ b/bauh/view/qt/window.py @@ -333,7 +333,7 @@ class ManageWindow(QWidget): def _show_warnings(self, warnings: List[str]): if warnings: - dialog.show_message(title=self.i18n['warning'].capitalize(), body='

{}

'.format('
'.join(warnings)), type_=MessageType.WARNING) + dialog.show_message(title=self.i18n['warning'].capitalize(), body='

{}

'.format('

'.join(warnings)), type_=MessageType.WARNING) def show(self): super(ManageWindow, self).show() From b22bf2786d2656adc7cdd576ca707dd3412eda75 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 12:59:08 -0300 Subject: [PATCH 2/8] Show button available for all information fields | AUR: not showing all optional dependencies --- CHANGELOG.md | 2 ++ bauh/gems/arch/pacman.py | 9 ++++----- bauh/view/qt/info.py | 14 +------------- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 270f610f..2cb619db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,10 +7,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## [0.6.1] ### Improvements: - Better warning presentation when there are several messages +- "Show" button available for all information fields ### Fixes: - Error when retrieving suggestions - snapd health check when snapd.service is available +- AUR: not showing all optional dependencies ( Info ) ## [0.6.0] 2019-09-25 diff --git a/bauh/gems/arch/pacman.py b/bauh/gems/arch/pacman.py index d2c85d27..a08c51b4 100644 --- a/bauh/gems/arch/pacman.py +++ b/bauh/gems/arch/pacman.py @@ -6,7 +6,7 @@ from bauh.api.abstract.handler import ProcessWatcher from bauh.commons.system import run_cmd, new_subprocess, new_root_subprocess, SystemProcess, ProcessHandler RE_DEPS = re.compile(r'[\w\-_]+:[\s\w_\-\.]+\s+\[\w+\]') - +RE_OPTDEPS = re.compile(r'[\w\._\-]+\s*:') def is_enabled() -> bool: try: @@ -43,7 +43,7 @@ def get_info(pkg_name) -> str: def get_info_list(pkg_name: str) -> List[tuple]: info = get_info(pkg_name) if info: - return re.findall(r'(\w+\s?\w+)\s+:\s+(.+(\n\s+.+)*)', info) + return re.findall(r'(\w+\s?\w+)\s*:\s*(.+(\n\s+.+)*)', info) def get_info_dict(pkg_name: str) -> dict: @@ -53,14 +53,13 @@ def get_info_dict(pkg_name: str) -> dict: info_dict = {} for info_data in info_list: attr = info_data[0].lower().strip() - info_dict[attr] = info_data[1] if '\n' not in info_data[1] else ' '.join( - [l.strip() for l in info_data[1].split('\n')]) + info_dict[attr] = info_data[1] if info_dict[attr] == 'None': info_dict[attr] = None if attr == 'optional deps' and info_dict[attr]: - info_dict[attr] = RE_DEPS.findall(info_dict[attr]) + info_dict[attr] = info_dict[attr].split('\n') elif attr == 'depends on' and info_dict[attr]: info_dict[attr] = [d.strip() for d in info_dict[attr].split(' ') if d] diff --git a/bauh/view/qt/info.py b/bauh/view/qt/info.py index f4cdf3ea..54f1d923 100644 --- a/bauh/view/qt/info.py +++ b/bauh/view/qt/info.py @@ -3,7 +3,6 @@ from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QDialog, QVBoxLayout, QGroupBox, \ QLineEdit, QLabel, QGridLayout, QPushButton, QPlainTextEdit, QToolBar from bauh.api.abstract.cache import MemoryCache -from bauh.commons.html import strip_html IGNORED_ATTRS = {'name', '__app__'} @@ -54,8 +53,6 @@ class InfoDialog(QDialog): else: val = str(app[attr]).strip() - full_val = None - i18n_val = locale_keys.get('{}.{}'.format(i18n_key, val.lower())) if i18n_val: @@ -63,13 +60,6 @@ class InfoDialog(QDialog): text = QLineEdit() text.setToolTip(val) - - if len(val) > 80: - full_val = val - self.full_vals.append(full_val) - val = strip_html(val) - val = val[0:80] + '...' - text.setText(val) text.setCursorPosition(0) text.setStyleSheet("width: 400px") @@ -80,9 +70,7 @@ class InfoDialog(QDialog): self.gbox_info_layout.addWidget(label, idx, 0) self.gbox_info_layout.addWidget(text, idx, 1) - - if full_val is not None: - self._gen_show_button(idx, full_val) + self._gen_show_button(idx, val) self.adjustSize() From 86a0e402e9d452bfc77ec11fe51e8e7173f74d91 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 16:54:54 -0300 Subject: [PATCH 3/8] Better AUR update check handling --- CHANGELOG.md | 3 +- bauh/gems/arch/mapper.py | 42 +++++- setup.py | 3 +- tests/__init__.py | 0 tests/gems/__init__.py | 0 tests/gems/arch/__init__.py | 0 tests/gems/arch/arch_data_mapper_test.py | 175 +++++++++++++++++++++++ 7 files changed, 220 insertions(+), 3 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/gems/__init__.py create mode 100644 tests/gems/arch/__init__.py create mode 100644 tests/gems/arch/arch_data_mapper_test.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cb619db..d54e10d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,10 @@ 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.6.1] +## [0.6.1] 2019-09- ### Improvements: - Better warning presentation when there are several messages +- Better AUR update check handling - "Show" button available for all information fields ### Fixes: diff --git a/bauh/gems/arch/mapper.py b/bauh/gems/arch/mapper.py index cdaa1828..72db9469 100644 --- a/bauh/gems/arch/mapper.py +++ b/bauh/gems/arch/mapper.py @@ -1,3 +1,4 @@ +import re from datetime import datetime from bauh.api.abstract.model import PackageStatus @@ -5,6 +6,16 @@ from bauh.api.http import HttpClient from bauh.gems.arch.model import ArchPackage URL_PKG_DOWNLOAD = 'https://aur.archlinux.org/{}' +RE_LETTERS = re.compile(r'\.([a-zA-Z]+)-\d+$') + +RE_SFX = ('r', 're', 'release') +GA_SFX = ('ga', 'ge') +RC_SFX = ('rc',) +BETA_SFX = ('b', 'beta') +AL_SFX = ('alpha', 'alfa') +DEV_SFX = ('dev', 'devel', 'development') + +V_SUFFIX_MAP = {s: {'c': sfxs[0], 'p': idx} for idx, sfxs in enumerate([RE_SFX, GA_SFX, RC_SFX, BETA_SFX, AL_SFX, DEV_SFX]) for s in sfxs} class ArchDataMapper: @@ -36,7 +47,36 @@ class ArchDataMapper: pkg.url_download = URL_PKG_DOWNLOAD.format(package['URLPath']) if package.get('URLPath') else None pkg.first_submitted = datetime.fromtimestamp(package['FirstSubmitted']) if package.get('FirstSubmitted') else None pkg.last_modified = datetime.fromtimestamp(package['LastModified']) if package.get('LastModified') else None - pkg.update = pkg.version and pkg.latest_version and pkg.latest_version > pkg.version + pkg.update = self.check_update(pkg.version, pkg.latest_version) + + @staticmethod + def check_update(version: str, latest_version: str) -> bool: + if version and latest_version: + current_sfx = RE_LETTERS.findall(version) + latest_sf = RE_LETTERS.findall(latest_version) + + if latest_sf and current_sfx: + current_sfx = current_sfx[0] + latest_sf = latest_sf[0] + + current_sfx_data = V_SUFFIX_MAP.get(current_sfx.lower()) + latest_sfx_data = V_SUFFIX_MAP.get(latest_sf.lower()) + + if current_sfx_data and latest_sfx_data: + nversion = version.split(current_sfx)[0] + nlatest = latest_version.split(latest_sf)[0] + + if nversion == nlatest: + if current_sfx_data['c'] != latest_sfx_data['c']: + return latest_sfx_data['p'] < current_sfx_data['p'] + else: + return ''.join(latest_version.split(latest_sf)) > ''.join(version.split(current_sfx)) + + return nlatest > nversion + + return latest_version > version + + return False def fill_package_build(self, pkg: ArchPackage): res = self.http_client.get(pkg.get_pkg_build_url()) diff --git a/setup.py b/setup.py index 1fa96690..a0de0e07 100644 --- a/setup.py +++ b/setup.py @@ -30,9 +30,10 @@ setup( author_email=AUTHOR_EMAIL, python_requires=">=3.5", url=URL, - packages=find_packages(), + packages=find_packages(exclude=["tests.*", "tests"]), package_data={NAME: ["view/resources/locale/*", "view/resources/img/*", "gems/*/resources/img/*", "gems/*/resources/locale/*"]}, install_requires=requirements, + test_suite="tests", entry_points={ "console_scripts": [ "{name}={name}.app:main".format(name=NAME) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/gems/__init__.py b/tests/gems/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/gems/arch/__init__.py b/tests/gems/arch/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/gems/arch/arch_data_mapper_test.py b/tests/gems/arch/arch_data_mapper_test.py new file mode 100644 index 00000000..218894a6 --- /dev/null +++ b/tests/gems/arch/arch_data_mapper_test.py @@ -0,0 +1,175 @@ +from unittest import TestCase + +from bauh.gems.arch.mapper import ArchDataMapper + + +class ArchDataMapperTest(TestCase): + + def test_check_update_no_suffix(self): + self.assertTrue(ArchDataMapper.check_update('1.0.0-1', '1.0.0-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0-2', '1.0.0-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0-5', '1.0.1-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.1-1', '1.0.0-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.5-5', '1.1.0-2')) + self.assertFalse(ArchDataMapper.check_update('1.1.0-2', '1.0.5-5')) + self.assertTrue(ArchDataMapper.check_update('1.5.0-2', '1.5.1-1')) + self.assertFalse(ArchDataMapper.check_update('1.5.1-1', '1.5.0-2')) + self.assertTrue(ArchDataMapper.check_update('1.5.1-1', '1.5.1-2')) + self.assertTrue(ArchDataMapper.check_update('1.5.1-1', '2.0.0-1')) + self.assertFalse(ArchDataMapper.check_update('2.0.0-1', '1.5.1-1')) + + def test_check_update_release(self): + # RE + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.R-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-2', '1.0.0.R-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.1.R-1', '1.0.0.R-5')) + self.assertTrue(ArchDataMapper.check_update('1.0.1.R-1', '1.0.1.R-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.2.R-1', '1.0.1.R-7')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.R-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RELEASE-2', '1.0.0.R-5')) + self.assertFalse(ArchDataMapper.check_update('1.0.1.R-1', '1.0.0.RELEASE-5')) + self.assertFalse(ArchDataMapper.check_update('1.0.1.R-1', '1.0.0.RE-1')) + + # GA + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.Ge-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.GA-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.Ge-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.GE-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.GE-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.GE-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.GA-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.GA-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.GA-1')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-5', '1.0.1.GA-1')) + + # RCS + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.RC-1')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-5', '1.0.1.RC-1')) + + # BETA + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.B-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.B-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.B-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.BETA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.BETA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.BETA-2')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-5', '1.0.1.BETA-1')) + + # ALPHA + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.Alpha-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.ALPHA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.ALPHA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.ALPHA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.ALPHA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.ALPHA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.ALFA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.ALFA-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.ALFA-2')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-5', '1.0.1.Alfa-1')) + + # DEV + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.DeV-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.DEV-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.DEVEL-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.R-1', '1.0.0.DEV-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.DEV-2')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.RELEASE-1', '1.0.0.DEV-2')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.R-5', '1.0.1.DEV-1')) + + def test_check_update_ga(self): + # GA + self.assertFalse(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.0.GE-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.0.GA-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.GA-2', '1.0.1.GA-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.GE-3', '1.0.6.GE-10')) + + # RC + self.assertFalse(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.0.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.0.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.0.RC-1')) + + self.assertTrue(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.1.RC-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.10.GA-10', '1.1.0.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.GE-1', '1.0.1.RC-1')) + + # BETA + self.assertFalse(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.0.BETA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.1.BETA-1')) + + # ALPHA + self.assertFalse(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.0.ALPHA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.1.ALPHA-1')) + + # DEV + self.assertFalse(ArchDataMapper.check_update('1.0.0.GA-1', '1.0.0.DEV-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.GE-1', '1.0.1.DEV-1')) + + def test_check_update_rc(self): + # RC + self.assertFalse(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.0.RC-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.0.RC-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RC-2', '1.0.1.RC-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.RC-3', '1.0.6.RC-10')) + + # BETA + self.assertFalse(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.0.BETA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.1.BETA-1')) + + # ALPHA + self.assertFalse(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.0.ALPHA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.1.ALPHA-1')) + + # DEV + self.assertFalse(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.0.DEV-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.RC-1', '1.0.1.DEV-1')) + + def test_check_update_beta(self): + # BETA + self.assertFalse(ArchDataMapper.check_update('1.0.0.BETA-1', '1.0.0.BETA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.BETA-1', '1.0.0.BETA-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.BETA-2', '1.0.1.B-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.B-3', '1.0.6.BETA-10')) + + # ALPHA + self.assertFalse(ArchDataMapper.check_update('1.0.0.BETA-1', '1.0.0.ALPHA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.B-1', '1.0.1.ALPHA-1')) + + # DEV + self.assertFalse(ArchDataMapper.check_update('1.0.0.BETA-1', '1.0.0.DEV-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.B-1', '1.0.1.DEV-1')) + + def test_check_update_alpha(self): + # ALPHA + self.assertFalse(ArchDataMapper.check_update('1.0.0.ALPHA-1', '1.0.0.ALPHA-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.ALPHA-1', '1.0.0.ALFA-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.ALFA-1', '1.0.0.ALPHA-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.ALPHA-2', '1.0.1.ALFA-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.ALFA-3', '1.0.6.ALFA-10')) + + # DEV + self.assertFalse(ArchDataMapper.check_update('1.0.0.ALFA-1', '1.0.0.DEV-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.ALPHA-1', '1.0.1.DEV-1')) + + def test_check_update_dev(self): + self.assertFalse(ArchDataMapper.check_update('1.0.0.DEV-1', '1.0.0.DEV-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.DEV-1', '1.0.0.DEVEL-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.DEVEL-1', '1.0.0.DEVELOPMENT-1')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.DEV-1', '1.0.0.DEVEL-2')) + self.assertTrue(ArchDataMapper.check_update('1.0.0.DEVEL-2', '1.0.1.DEV-1')) + self.assertFalse(ArchDataMapper.check_update('1.1.0.DEV-3', '1.0.6.DEVELOPMENT-10')) + + def test_check_update_unknown_suffix(self): + self.assertTrue(ArchDataMapper.check_update('1.0.0.BALL-1', '1.0.0.TAR-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.TAR-1', '1.0.0.BALL-1')) + + def test_check_update_known_and_unknown_suffix(self): + self.assertTrue(ArchDataMapper.check_update('1.0.0.RE-1', '1.0.0.TAR-1')) + self.assertFalse(ArchDataMapper.check_update('1.0.0.TAR-1', '1.0.0.RE-1')) From 6a326ec1bc182ec6d1bc9c0c916337779e9d1862 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 16:56:19 -0300 Subject: [PATCH 4/8] changing version to 0.6.1 --- bauh/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/__init__.py b/bauh/__init__.py index 6dfd2e60..68a0a495 100644 --- a/bauh/__init__.py +++ b/bauh/__init__.py @@ -1,4 +1,4 @@ -__version__ = '0.6.0' +__version__ = '0.6.1' __app_name__ = 'bauh' import os From 5f8e30ed71df831f8112a9114f1e1eb57f6e480a Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 17:09:50 -0300 Subject: [PATCH 5/8] removing unused import --- bauh/gems/snap/controller.py | 1 - 1 file changed, 1 deletion(-) diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index dba2decd..3cf22d9f 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -8,7 +8,6 @@ from bauh.api.abstract.disk import DiskCacheLoader from bauh.api.abstract.handler import ProcessWatcher from bauh.api.abstract.model import SoftwarePackage, PackageHistory, PackageUpdate, PackageSuggestion, \ SuggestionPriority -from bauh.commons import internet from bauh.commons.html import bold from bauh.commons.system import SystemProcess, ProcessHandler from bauh.gems.snap import snap, suggestions From 8a4bbc53e7b7a69b220b1b2e525cdb1fee930c35 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 17:16:13 -0300 Subject: [PATCH 6/8] fix: not showing snap warning when snap command is not available --- bauh/gems/snap/controller.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bauh/gems/snap/controller.py b/bauh/gems/snap/controller.py index 3cf22d9f..1bcbd3a4 100644 --- a/bauh/gems/snap/controller.py +++ b/bauh/gems/snap/controller.py @@ -144,7 +144,7 @@ class SnapManager(SoftwareManager): pass def list_warnings(self) -> List[str]: - if not snap.is_snapd_running(): + if snap.is_installed() and not snap.is_snapd_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(self.i18n['manage_window.settings.gems']))] From ac3128ce5a32eb93623944ce2a0b8c4583353a30 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 17:36:06 -0300 Subject: [PATCH 7/8] Snap warning i18n improvement --- bauh/gems/snap/resources/locale/es | 2 +- bauh/gems/snap/resources/locale/pt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bauh/gems/snap/resources/locale/es b/bauh/gems/snap/resources/locale/es index 935d8dc2..1d31611a 100644 --- a/bauh/gems/snap/resources/locale/es +++ b/bauh/gems/snap/resources/locale/es @@ -7,7 +7,7 @@ snap.info.revision=revisión snap.info.tracking=tracking snap.info.installed=instalado snap.info.publisher=publicador -snap.notification.snapd_unavailable={} no parece estar instalado o habilitado. los paquetes {} estarán indisponibles. +snap.notification.snapd_unavailable={} no parece estar instalado o habilitado. Los paquetes {} estarán indisponibles. snap.notification.snap.disable=Si no desea usar aplicativos Snap, desmarque {} en {} snap.action.refresh.status=Actualizando snap.action.refresh.label=Actualizar \ No newline at end of file diff --git a/bauh/gems/snap/resources/locale/pt b/bauh/gems/snap/resources/locale/pt index 000a5c90..efd0aa98 100644 --- a/bauh/gems/snap/resources/locale/pt +++ b/bauh/gems/snap/resources/locale/pt @@ -7,7 +7,7 @@ snap.info.revision=revisão snap.info.tracking=tracking snap.info.installed=instalado snap.info.publisher=publicador -snap.notification.snapd_unavailable={} não parece estar instalado ou habilitado. os pacotes {} estarão indisponíveis. +snap.notification.snapd_unavailable={} não parece estar instalado ou habilitado. Os pacotes {} estarão indisponíveis. snap.notification.snap.disable=Se não deseja usar aplicativos Snap, desmarque {} em {} snap.action.refresh.status=Atualizando snap.action.refresh.label=Atualizar \ No newline at end of file From e0d39d565d3ed18c9ca39d9fad2554900275c0f5 Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Thu, 26 Sep 2019 18:41:34 -0300 Subject: [PATCH 8/8] CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d54e10d5..fa45bd9b 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.6.1] 2019-09- +## [0.6.1] 2019-09-26 ### Improvements: - Better warning presentation when there are several messages - Better AUR update check handling