Skip to content

Commit

Permalink
0.9.15
Browse files Browse the repository at this point in the history
  • Loading branch information
vinifmor authored Mar 3, 2021
2 parents 9af8dd4 + a5c9ecd commit 8b81501
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 47 deletions.
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ 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.15] 2021-03-03
### Improvements
- UI
- checking if the internet connection is available before trying to upgrade the selected packages

### Fixes
- AppImage
- crashing when trying to upgrade and the internet connection is off

- Arch
- Upgrading: when an installed package does not meet a dependency expression, it is displayed to be installed (e.g: 'optimus-manager-qt' relies on 'optimus-manager' >= 1.4, but the current provided version is '1.3'. Even so, 'optimus-manager' will be displayed to be installed)
- Not checking the dependency version expression when it is only available on AUR
- Not properly treating a dependency version before comparing with others (could display that a given dependency was not found)

- Flatpak
- displaying duplicate runtimes on the upgrade summary when a runtime is available at the system and user levels
- installation level tooltip not being localized
- displaying installation level tooltip for not installed apps

- UI
- wrongly formatted tooltips
- conflict resolution: still displaying that updates are ignored for a given package after its uninstallation


## [0.9.14] 2021-02-03
### Improvements
- AppImage
Expand Down
2 changes: 1 addition & 1 deletion bauh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.9.14'
__version__ = '0.9.15'
__app_name__ = 'bauh'

import os
Expand Down
18 changes: 11 additions & 7 deletions bauh/api/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,17 @@ def get_yaml(self, url: str, params: dict = None, headers: dict = None, allow_re
res = self.get(url, params=params, headers=headers, allow_redirects=allow_redirects, session=session)
return yaml.safe_load(res.text) if res else None

def get_content_length_in_bytes(self, url: str, session: bool = True) -> int:
def get_content_length_in_bytes(self, url: str, session: bool = True) -> Optional[int]:
params = {'url': url, 'allow_redirects': True, 'stream': True}
if session:
res = self.session.get(**params)
else:
res = requests.get(**params)

try:
if session:
res = self.session.get(**params)
else:
res = requests.get(**params)
except requests.exceptions.ConnectionError:
self.logger.info("Internet seems to be off. Could not reach '{}'".format(url))
return

if res.status_code == 200:
size = res.headers.get('Content-Length')
Expand All @@ -84,7 +89,7 @@ def get_content_length_in_bytes(self, url: str, session: bool = True) -> int:
except:
pass

def get_content_length(self, url: str, session: bool = True) -> str:
def get_content_length(self, url: str, session: bool = True) -> Optional[str]:
size = self.get_content_length_in_bytes(url, session)

if size:
Expand All @@ -98,4 +103,3 @@ def exists(self, url: str, session: bool = True, timeout: int = 5) -> bool:
res = self.session.get(**params)

return res.status_code in (200, 403)
return False
65 changes: 43 additions & 22 deletions bauh/gems/arch/dependencies.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import re
import traceback
from threading import Thread
from typing import Set, List, Tuple, Dict, Iterable
from typing import Set, List, Tuple, Dict, Iterable, Optional

from packaging.version import parse as parse_version

from bauh.api.abstract.handler import ProcessWatcher
from bauh.gems.arch import pacman, message, sorting, confirmation
from bauh.gems.arch.aur import AURClient
from bauh.gems.arch.exceptions import PackageNotFoundException
from bauh.gems.arch.util import clean_version
from bauh.view.util.translation import I18n


Expand Down Expand Up @@ -204,7 +205,7 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
if match:
providers = {match}

if providers and len(providers) > 1:
if providers:
no_mapped_data = {p for p in providers if
p not in deps_data} # checking providers with no mapped data

Expand All @@ -219,7 +220,7 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
matched_providers = set()
split_informed_dep = self.re_dep_operator.split(dep_exp)
try:
version_informed = parse_version(split_informed_dep[2])
version_required = parse_version(clean_version(split_informed_dep[2]))
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='

for p in providers:
Expand All @@ -229,9 +230,9 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
split_dep = self.re_dep_operator.split(provided_exp)

if len(split_dep) == 3 and split_dep[0] == dep_name:
provided_version = parse_version(split_dep[2])
version_provided = parse_version(clean_version(split_dep[2]))

if eval('provided_version {} version_informed'.format(exp_op)):
if eval('version_provided {} version_required'.format(exp_op)):
matched_providers.add(p)
break

Expand Down Expand Up @@ -259,14 +260,40 @@ def _fill_missing_dep(self, dep_name: str, dep_exp: str, aur_index: Iterable[str
missing_deps.add(dep_data)

elif aur_index and dep_name in aur_index:
aur_deps.add(dep_name)
missing_deps.add((dep_name, 'aur'))
else:
if watcher:
message.show_dep_not_found(dep_exp, self.i18n, watcher)
raise PackageNotFoundException(dep_exp)
if dep_name == dep_exp:
aur_deps.add(dep_name)
missing_deps.add((dep_name, 'aur'))
else:
raise PackageNotFoundException(dep_exp)
dep_info = self.aur_client.get_info({dep_name})

if not dep_info:
self.__raise_dependency_not_found(dep_exp, watcher)
else:
try:
dep_version = parse_version(clean_version(dep_info[0]['Version']))
except:
traceback.print_exc()
self.__raise_dependency_not_found(dep_exp, watcher)

split_informed_dep = self.re_dep_operator.split(dep_exp)
try:
version_required = parse_version(clean_version(split_informed_dep[2]))
exp_op = split_informed_dep[1] if split_informed_dep[1] != '=' else '=='

if eval('dep_version {} version_required'.format(exp_op)):
aur_deps.add(dep_name)
missing_deps.add((dep_name, 'aur'))
except:
self.__raise_dependency_not_found(dep_exp, watcher)
else:
self.__raise_dependency_not_found(dep_exp, watcher)

def __raise_dependency_not_found(self, dep_exp: str, watcher: Optional[ProcessWatcher]):
if watcher:
message.show_dep_not_found(dep_exp, self.i18n, watcher)
raise PackageNotFoundException(dep_exp)
else:
raise PackageNotFoundException(dep_exp)

def __fill_aur_update_data(self, pkgname: str, output: dict):
output[pkgname] = self.aur_client.map_update_data(pkgname, None)
Expand Down Expand Up @@ -307,21 +334,15 @@ def map_missing_deps(self, pkgs_data: Dict[str, dict], provided_map: Dict[str, S
version_found = [p for p in provided_map if p.startswith(version_pattern)]

if version_found:
version_found = version_found[0].split('=')[1]
version_informed = dep_split[2].strip()

if ':' not in version_informed:
version_found = version_found.split(':')[-1]

if '-' not in version_informed:
version_found = version_found.split('-')[0]
version_found = clean_version(version_found[0].split('=')[1])
version_required = clean_version(dep_split[2])

try:
version_found = parse_version(version_found)
version_informed = parse_version(version_informed)
version_required = parse_version(version_required)

op = dep_split[1] if dep_split[1] != '=' else '=='
match = eval('version_found {} version_informed'.format(op))
match = eval('version_found {} version_required'.format(op))
except:
match = False
traceback.print_exc()
Expand Down
12 changes: 12 additions & 0 deletions bauh/gems/arch/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import re

RE_STRIP_EPIC = re.compile(r'^\d+:')
RE_STRIP_RELEASE = re.compile(r'-[\d\.?]+$')


def clean_version(version: str) -> str:
treated_version = version.strip()
if treated_version:
return RE_STRIP_RELEASE.split(RE_STRIP_EPIC.split(treated_version)[-1])[0]

return treated_version
3 changes: 2 additions & 1 deletion bauh/gems/flatpak/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,9 @@ def sort_update_order(self, pkgs: List[FlatpakApplication]) -> List[FlatpakAppli
all_runtimes = []
for runtime in runtimes:
for partial in partials:
if partial.base_id == runtime.id:
if partial.installation == runtime.installation and partial.base_id == runtime.id:
all_runtimes.append(partial)
break

all_runtimes.append(runtime)
return [*all_runtimes, *apps]
Expand Down
6 changes: 3 additions & 3 deletions bauh/gems/flatpak/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ def gen_partial(self, partial_id: str) -> "FlatpakApplication":
partial.base_ref = self.ref
partial.ref = '/'.join((partial_id, *self.ref.split('/')[1:]))
partial.status = PackageStatus.READY
partial.name += ' ( {} )'.format(partial_id.split('.')[-1])
partial.name += ' ({})'.format(partial_id.split('.')[-1])

return partial

def get_name_tooltip(self) -> str:
if self.installation and self.i18n is not None:
return '{} ( {} )'.format(self.name, self.i18n[self.installation.lower()])
if self.installed and self.installation and self.i18n is not None:
return '{} ({})'.format(self.name, self.i18n['flatpak.info.installation.{}'.format(self.installation.lower().strip())])

return self.name

Expand Down
4 changes: 2 additions & 2 deletions bauh/view/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def _gen_tray_settings(self, core_config: dict, screen_width: int, screen_height

allowed_exts = {'png', 'svg', 'jpg', 'jpeg', 'ico', 'xpm'}
select_def_icon = FileChooserComponent(id_='def_icon',
label=self.i18n["core.config.ui.tray.default_icon"].capitalize(),
tooltip=self.i18n["core.config.ui.tray.default_icon.tip"].capitalize(),
label=self.i18n["core.config.ui.tray.default_icon"],
tooltip=self.i18n["core.config.ui.tray.default_icon.tip"],
file_path=str(core_config['ui']['tray']['default_icon']) if core_config['ui']['tray']['default_icon'] else None,
max_width=default_width,
allowed_extensions=allowed_exts)
Expand Down
4 changes: 2 additions & 2 deletions bauh/view/qt/apps_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,11 @@ def _set_col_version(self, col: int, pkg: PackageView):
else:
tooltip = self.i18n['version.unknown']

if pkg.model.update and not pkg.model.is_update_ignored():
if pkg.model.installed and pkg.model.update and not pkg.model.is_update_ignored():
label_version.setProperty('update', 'true')
tooltip = pkg.model.get_update_tip() or self.i18n['version.installed_outdated']

if pkg.model.is_update_ignored():
if pkg.model.installed and pkg.model.is_update_ignored():
label_version.setProperty('ignored', 'true')
tooltip = self.i18n['version.updates_ignored']

Expand Down
15 changes: 14 additions & 1 deletion bauh/view/qt/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from bauh.api.exception import NoInternetException
from bauh.commons import user
from bauh.commons.html import bold
from bauh.commons.internet import InternetChecker
from bauh.commons.system import get_human_size_str, ProcessHandler, SimpleProcess
from bauh.view.core import timeshift
from bauh.view.core.config import CoreConfigManager
Expand Down Expand Up @@ -202,11 +203,12 @@ class UpgradeSelected(AsyncAction):
LOGS_DIR = '{}/upgrade'.format(LOGS_PATH)
SUMMARY_FILE = LOGS_DIR + '/{}_summary.txt'

def __init__(self, manager: SoftwareManager, i18n: I18n, pkgs: List[PackageView] = None):
def __init__(self, manager: SoftwareManager, internet_checker: InternetChecker, i18n: I18n, pkgs: List[PackageView] = None):
super(UpgradeSelected, self).__init__()
self.pkgs = pkgs
self.manager = manager
self.i18n = i18n
self.internet_checker = internet_checker

def _req_as_option(self, req: UpgradeRequirement, tooltip: bool = True, custom_tooltip: str = None, required_size: bool = True, display_sizes: bool = True) -> InputOption:
if req.pkg.installed:
Expand Down Expand Up @@ -386,7 +388,15 @@ def _write_summary_log(self, upgrade_id: str, requirements: UpgradeRequirements)
except:
traceback.print_exc()

def _handle_internet_off(self):
self.pkgs = None
self.print(self.i18n['internet.required'])
self.notify_finished({'success': False, 'updated': 0, 'types': set(), 'id': None})

def run(self):
if not self.internet_checker.is_available():
return self._handle_internet_off()

root_user = user.is_root()
to_update, upgrade_requires_root, bkp_supported = [], False, False

Expand Down Expand Up @@ -464,6 +474,9 @@ def run(self):
self.pkgs = None
return

if not self.internet_checker.is_available():
return self._handle_internet_off()

self.change_substatus('')

app_config = CoreConfigManager().get_config()
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/qt/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def __init__(self, i18n: I18n, icon_cache: MemoryCache, manager: SoftwareManager
self.layout.addWidget(self.toolbar_substatus)
self._change_label_substatus('')

self.thread_update = self._bind_async_action(UpgradeSelected(self.manager, self.i18n), finished_call=self._finish_upgrade_selected)
self.thread_update = self._bind_async_action(UpgradeSelected(self.manager, context.internet_checker, self.i18n), finished_call=self._finish_upgrade_selected)
self.thread_refresh = self._bind_async_action(RefreshApps(self.manager), finished_call=self._finish_refresh_packages, only_finished=True)
self.thread_uninstall = self._bind_async_action(UninstallPackage(self.manager, self.icon_cache, self.i18n), finished_call=self._finish_uninstall)
self.thread_show_info = self._bind_async_action(ShowPackageInfo(self.manager), finished_call=self._finish_show_info)
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/ca
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ core.config.ui.scale_factor.tip=It defines the interface display scaling factor
core.config.ui.system_theme=System theme
core.config.ui.system_theme.tip=If the system's theme/stylesheet should be merged with {app}'s
core.config.ui.tray.default_icon=Default icon
core.config.ui.tray.default_icon.tip=The default icon for {app} displayed on the tray
core.config.ui.tray.default_icon.tip=The default icon displayed on the tray
core.config.ui.tray.updates_icon=Update icon
core.config.ui.tray.updates_icon.tip=The displayed icon when there are updates available
core.config.updates.interval=Updates interval
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/de
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ core.config.ui.scale_factor.tip=It defines the interface display scaling factor
core.config.ui.system_theme=System theme
core.config.ui.system_theme.tip=If the system's theme/stylesheet should be merged with {app}'s
core.config.ui.tray.default_icon=Anwendungs-Icon
core.config.ui.tray.default_icon.tip=The default icon for {app} displayed on the tray
core.config.ui.tray.default_icon.tip=The default icon displayed on the tray
core.config.ui.tray.updates_icon=Icon bei Updates
core.config.ui.tray.updates_icon.tip=The displayed icon when there are updates available
core.config.updates.interval=Update-Intervall
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/en
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ core.config.ui.scale_factor=Scale
core.config.ui.scale_factor.tip=It defines the interface display scaling factor (Qt). Raise the value to raise the interface size. Restart required.
core.config.ui.system_theme=System theme
core.config.ui.system_theme.tip=If the system's theme/stylesheet should be merged with {app}'s
core.config.ui.tray.default_icon.tip=The default icon for {app} displayed on the tray
core.config.ui.tray.default_icon.tip=The default icon displayed on the tray
core.config.ui.tray.default_icon=Default icon
core.config.ui.tray.updates_icon.tip=The displayed icon when there are updates available
core.config.ui.tray.updates_icon=Update icon
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/fr
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ core.config.ui.max_displayed=Applications affichées
core.config.ui.qt_style.tooltip=QT style to be used. Requires restarting to take effect.
core.config.ui.scale_factor=Mettre à l'échelle
core.config.ui.scale_factor.tip=Définit le facteur de mise à l'échelle (Qt). L'augmenter agrandit l'interface. Redémarrage nécessaire.
core.config.ui.tray.default_icon.tip=Icône par défaut pour {app} dans la barre système
core.config.ui.tray.default_icon.tip=Icône par défaut dans la barre système
core.config.ui.tray.default_icon=Icône par dafaut
core.config.ui.tray.updates_icon.tip=Icône affichée quand il y a des mises à jour disponibles
core.config.ui.tray.updates_icon=Icône de mise à jour
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/it
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ core.config.ui.scale_factor.tip=It defines the interface display scaling factor
core.config.ui.system_theme=System theme
core.config.ui.system_theme.tip=If the system's theme/stylesheet should be merged with {app}'s
core.config.ui.tray.default_icon=Default icon
core.config.ui.tray.default_icon.tip=The default icon for {app} displayed on the tray
core.config.ui.tray.default_icon.tip=The default icon displayed on the tray
core.config.ui.tray.updates_icon=Update icon
core.config.ui.tray.updates_icon.tip=The displayed icon when there are updates available
core.config.updates.interval=Updates interval
Expand Down
2 changes: 1 addition & 1 deletion bauh/view/resources/locale/ru
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ core.config.ui.scale_factor.tip=It defines the interface display scaling factor
core.config.ui.system_theme=System theme
core.config.ui.system_theme.tip=If the system's theme/stylesheet should be merged with {app}'s
core.config.ui.tray.default_icon=Значок по умолчанию
core.config.ui.tray.default_icon.tip=Значок по умолчанию для {app}, отображаемый в трее
core.config.ui.tray.default_icon.tip=Значок по умолчанию для, отображаемый в трее
core.config.ui.tray.updates_icon=Значок обновления
core.config.ui.tray.updates_icon.tip=Значок, отображаемый при наличии доступных обновлений
core.config.updates.interval=Интервал обновления
Expand Down
Loading

0 comments on commit 8b81501

Please sign in to comment.