fix: update notifications are not being displayed

This commit is contained in:
Vinicius Moreira
2019-09-28 13:09:37 -03:00
parent e91bd85fa8
commit fd2dbe7dd0
7 changed files with 62 additions and 28 deletions

View File

@@ -4,13 +4,20 @@ 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/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [0.6.2] 2019-09-
### Improvements
- Update notifications showing the number of updates by type as well
### Fixes
- Update-check daemon not showing notifications
## [0.6.1] 2019-09-26 ## [0.6.1] 2019-09-26
### Improvements: ### Improvements
- Better warning presentation when there are several messages - Better warning presentation when there are several messages
- Better AUR update check handling - Better AUR update check handling
- "Show" button available for all information fields - "Show" button available for all information fields
### Fixes: ### Fixes
- Error when retrieving suggestions - Error when retrieving suggestions
- snapd health check when snapd.service is available - snapd health check when snapd.service is available
- AUR: not showing all optional dependencies ( Info ) - AUR: not showing all optional dependencies ( Info )

View File

@@ -196,8 +196,9 @@ class SoftwareManager(ABC):
pass pass
@abstractmethod @abstractmethod
def list_updates(self) -> List[PackageUpdate]: def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
""" """
:param internet_available
:return: available package updates :return: available package updates
""" """
pass pass

View File

@@ -689,8 +689,9 @@ class ArchManager(SoftwareManager):
self.comp_optimizer.start() self.comp_optimizer.start()
self.aur_index_updater.start() self.aur_index_updater.start()
def list_updates(self) -> List[PackageUpdate]: def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
return [PackageUpdate(app.id, app.latest_version, 'aur') for app in self.read_installed(disk_loader=None).installed if app.update] installed = self.read_installed(disk_loader=None, internet_available=internet_available).installed
return [PackageUpdate(p.id, p.latest_version, 'aur') for p in installed if p.update]
def list_warnings(self) -> List[str]: def list_warnings(self) -> List[str]:
warnings = [] warnings = []

View File

@@ -184,9 +184,11 @@ class FlatpakManager(SoftwareManager):
def prepare(self): def prepare(self):
pass pass
def list_updates(self) -> List[PackageUpdate]: def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
to_update = [app for app in self.read_installed(None).installed if app.update]
updates = [] updates = []
installed = self.read_installed(None, internet_available=internet_available).installed
to_update = [p for p in installed if p.update]
if to_update: if to_update:
loaders = [] loaders = []

View File

@@ -140,7 +140,7 @@ class SnapManager(SoftwareManager):
def prepare(self): def prepare(self):
pass pass
def list_updates(self) -> List[PackageUpdate]: def list_updates(self, internet_available: bool) -> List[PackageUpdate]:
pass pass
def list_warnings(self) -> List[str]: def list_warnings(self) -> List[str]:

View File

@@ -143,12 +143,12 @@ class GenericSoftwareManager(SoftwareManager):
t.start() t.start()
return t return t
def read_installed(self, disk_loader: DiskCacheLoader = None, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = None) -> SearchResult: def read_installed(self, disk_loader: DiskCacheLoader = None, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, net_check: bool = None) -> SearchResult:
ti = time.time() ti = time.time()
self._wait_to_be_ready() self._wait_to_be_ready()
internet_available = {} net_check = {}
thread_internet_check = self._get_internet_check(internet_available) thread_internet_check = self._get_internet_check(net_check)
res = SearchResult([], None, 0) res = SearchResult([], None, 0)
@@ -165,7 +165,7 @@ class GenericSoftwareManager(SoftwareManager):
thread_internet_check.join() thread_internet_check.join()
mti = time.time() mti = time.time()
man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=internet_available['available']) man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=net_check['available'])
mtf = time.time() mtf = time.time()
self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti)) self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti))
@@ -184,7 +184,7 @@ class GenericSoftwareManager(SoftwareManager):
thread_internet_check.join() thread_internet_check.join()
mti = time.time() mti = time.time()
man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=internet_available['available']) man_res = man.read_installed(disk_loader=disk_loader, pkg_types=None, internet_available=net_check['available'])
mtf = time.time() mtf = time.time()
self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti)) self.logger.info(man.__class__.__name__ + " took {0:.2f} seconds".format(mtf - mti))
@@ -286,15 +286,22 @@ class GenericSoftwareManager(SoftwareManager):
self.thread_prepare = Thread(target=self._prepare) self.thread_prepare = Thread(target=self._prepare)
self.thread_prepare.start() self.thread_prepare.start()
def list_updates(self) -> List[PackageUpdate]: def list_updates(self, net_check: bool = None) -> List[PackageUpdate]:
self._wait_to_be_ready() self._wait_to_be_ready()
updates = [] updates = []
if self.managers: if self.managers:
net_check = {}
thread_internet_check = self._get_internet_check(net_check)
for man in self.managers: for man in self.managers:
if self._can_work(man): if self._can_work(man):
man_updates = man.list_updates()
if thread_internet_check.is_alive():
thread_internet_check.join()
man_updates = man.list_updates(internet_available=net_check['available'])
if man_updates: if man_updates:
updates.extend(man_updates) updates.extend(man_updates)

View File

@@ -1,4 +1,5 @@
import time import time
from io import StringIO
from threading import Lock, Thread from threading import Lock, Thread
from typing import List from typing import List
@@ -96,7 +97,22 @@ class TrayIcon(QSystemTrayIcon):
if update_keys.difference(self.last_updates): if update_keys.difference(self.last_updates):
self.last_updates = update_keys self.last_updates = update_keys
n_updates = len(updates) n_updates = len(updates)
msg = self.i18n['notification.update{}'.format('' if n_updates == 1 else 's')].format(n_updates) ups_by_type = {}
for key in update_keys:
ptype = key.split(':')[0]
count = ups_by_type.get(ptype)
count = 1 if count is None else count + 1
ups_by_type[ptype] = count
msg = StringIO()
msg.write(self.i18n['notification.update{}'.format('' if n_updates == 1 else 's')].format(n_updates))
for ptype, count in ups_by_type.items():
msg.write('\n * {} ( {} )'.format(ptype.capitalize(), count))
msg.seek(0)
msg = msg.read()
self.setToolTip(msg) self.setToolTip(msg)
if self.update_notification and notify_user: if self.update_notification and notify_user: