From 4eccc107ad43c51d92b0a71b186973cf5a9f6cd0 Mon Sep 17 00:00:00 2001 Message-Id: <4eccc107ad43c51d92b0a71b186973cf5a9f6cd0.1715241653.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 10 May 2015 11:13:30 +0100 Subject: [PATCH] check.d/50.updates: Maintain sets of packages, rather than lists. Organization: Straylight/Edgeware From: Mark Wooding --- check.d/50.updates | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/check.d/50.updates b/check.d/50.updates index 9eb27a4..0444fa1 100755 --- a/check.d/50.updates +++ b/check.d/50.updates @@ -26,9 +26,9 @@ def cache_up_to_date_p(): return now - last < 86400 def upgradable_packages(): - """Return a list of packages for which updates are available.""" + """Return a set of packages for which updates are available.""" cache = AC.Cache() - return [pkg for pkg in cache if pkg.is_upgradable] + return set([pkg for pkg in cache if pkg.is_upgradable]) def security_updates_p(pkg): """Answer whether any update for PKG is security-relevant.""" @@ -59,7 +59,7 @@ if updates: plural = len(updates) != 1 print 'I: updates available for %d %s' % \ (len(updates), plural and 'packages' or 'package') -sec = [pkg for pkg in updates if security_updates_p(pkg)] +sec = set(pkg for pkg in updates if security_updates_p(pkg)) if sec: plural = len(sec) != 1 print 'W: security updates available for %d %s' % \ -- [mdw]