From d48e661d970365874c868d592f929f52798affb2 Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Mon, 5 Jun 2017 15:06:56 +0200 Subject: [PATCH] [modules/traffic] Fix delta calculation A previous commit broke the traffic module by deleting widgets during each iteration. This is fatal as the widgets contain the traffic information from the previous iteration, for delta calculation. Store previous traffic data in the module itself instead. --- bumblebee/modules/traffic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bumblebee/modules/traffic.py b/bumblebee/modules/traffic.py index bb479e6..ee21794 100644 --- a/bumblebee/modules/traffic.py +++ b/bumblebee/modules/traffic.py @@ -23,6 +23,7 @@ class Module(bumblebee.engine.Module): self._exclude = tuple(filter(len, self.parameter("exclude", "lo,virbr,docker,vboxnet,veth").split(","))) self._status = "" + self._prev = {} self._states = {} self._states["include"] = [] self._states["exclude"] = [] @@ -90,9 +91,9 @@ class Module(bumblebee.engine.Module): for direction in ["rx", "tx"]: name = "traffic.{}-{}".format(direction, interface) widget = self.create_widget(widgets, name, attributes={"theme.minwidth": "1000.00MB"}) - prev = widget.get(direction, 0) + prev = self._prev.get(name, 0) speed = bumblebee.util.bytefmt(int(data[direction]) - int(prev)) widget.full_text(speed) - widget.set(direction, data[direction]) + self._prev[name] = data[direction] # vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4