[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
This commit is contained in:
parent
2d99bdf314
commit
0bfb725ae0
1 changed files with 2 additions and 3 deletions
|
@ -44,9 +44,6 @@ class Module(bumblebee.engine.Module):
|
||||||
self._update_widgets(widgets)
|
self._update_widgets(widgets)
|
||||||
|
|
||||||
def create_widget(self, widgets, name, txt=None, attributes={}):
|
def create_widget(self, widgets, name, txt=None, attributes={}):
|
||||||
widget = self.widget(name)
|
|
||||||
if widget: return widget
|
|
||||||
|
|
||||||
widget = bumblebee.output.Widget(name=name)
|
widget = bumblebee.output.Widget(name=name)
|
||||||
widget.full_text(txt)
|
widget.full_text(txt)
|
||||||
widgets.append(widget)
|
widgets.append(widget)
|
||||||
|
@ -69,6 +66,8 @@ class Module(bumblebee.engine.Module):
|
||||||
def _update_widgets(self, widgets):
|
def _update_widgets(self, widgets):
|
||||||
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
|
interfaces = [ i for i in netifaces.interfaces() if not i.startswith(self._exclude) ]
|
||||||
|
|
||||||
|
del widgets[:]
|
||||||
|
|
||||||
counters = psutil.net_io_counters(pernic=True)
|
counters = psutil.net_io_counters(pernic=True)
|
||||||
for interface in interfaces:
|
for interface in interfaces:
|
||||||
if not interface: interface = "lo"
|
if not interface: interface = "lo"
|
||||||
|
|
Loading…
Reference in a new issue