From 52ef0e07df4b9a032014f4383d0c84f769137eb0 Mon Sep 17 00:00:00 2001 From: ncoop Date: Sat, 9 Apr 2016 02:29:48 -0700 Subject: [PATCH] Not all lines after the second are updates. There are 14 here: ``` Last metadata expiration check: 1:16:29 ago on Sat Apr 9 01:14:36 2016. google-chrome-stable.x86_64 49.0.2623.112-1 google-chrome kernel.x86_64 4.4.6-301.fc23 updates kernel-core.x86_64 4.4.6-301.fc23 updates kernel-debug-devel.x86_64 4.4.6-301.fc23 updates kernel-devel.x86_64 4.4.6-301.fc23 updates kernel-headers.x86_64 4.4.6-301.fc23 updates kernel-modules.x86_64 4.4.6-301.fc23 updates kernel-modules-extra.x86_64 4.4.6-301.fc23 updates openssh.x86_64 7.2p2-2.fc23 updates openssh-askpass.x86_64 7.2p2-2.fc23 updates openssh-clients.x86_64 7.2p2-2.fc23 updates openssh-server.x86_64 7.2p2-2.fc23 updates webkitgtk3.x86_64 2.4.10-2.fc23 updates Obsoleting Packages kernel-headers.x86_64 4.4.6-301.fc23 updates kernel-headers.x86_64 4.4.6-300.fc23 @updates ``` --- i3pystatus/updates/dnf.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/i3pystatus/updates/dnf.py b/i3pystatus/updates/dnf.py index a8180b2..efd4bda 100644 --- a/i3pystatus/updates/dnf.py +++ b/i3pystatus/updates/dnf.py @@ -1,5 +1,6 @@ from i3pystatus.core.command import run_through_shell from i3pystatus.updates import Backend +from re import split class Dnf(Backend): @@ -16,7 +17,9 @@ class Dnf(Backend): update_count = 0 if dnf.rc == 100: - update_count = len(dnf.out.split("\n")[2:-1]) + lines = dnf.out.splitlines()[2:] + lines = [l for l in lines if len(split("\s{2,}", l.rstrip())) == 3] + update_count = len(lines) return update_count Backend = Dnf