From 0bfb725ae091cfed0f8c488587c54d28c38fa2a7 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Sat, 3 Jun 2017 15:26:00 +0200 Subject: [PATCH] [modules/traffic] Recreate widget list during each iteration To avoid "stray" devices being kept in the list, empty the widgets list during each iteration and re-populate it from the list of available interfaces. fixes #101 --- bumblebee/modules/traffic.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index 09b7a3e..bb479e6 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -44,9 +44,6 @@ class Module(bumblebee.engine.Module): self._update_widgets(widgets) def create_widget(self, widgets, name, txt=None, attributes={}): - widget = self.widget(name) - if widget: return widget - widget = bumblebee.output.Widget(name=name) widget.full_text(txt) widgets.append(widget) @@ -69,6 +66,8 @@ class Module(bumblebee.engine.Module): def _update_widgets(self, widgets): interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ] + del widgets[:] + counters = psutil.net_io_counters(pernic=True) for interface in interfaces: if not interface: interface = "lo"