aboutsummaryrefslogtreecommitdiffstats
path: root/plasma
diff options
context:
space:
mode:
authorEugeni Dodonov <eugeni@mandriva.com>2011-01-24 13:24:12 -0200
committerEugeni Dodonov <eugeni@mandriva.com>2011-01-24 13:24:12 -0200
commit35d425fe12fdde40bbdb75d1bbae1cbafe6c271e (patch)
tree653a1ace69866658d18a286961ad3020a880f096 /plasma
parenteee7802f9c360db58bcf636dda2d9832e4891cac (diff)
downloadnet_monitor-35d425fe12fdde40bbdb75d1bbae1cbafe6c271e.tar
net_monitor-35d425fe12fdde40bbdb75d1bbae1cbafe6c271e.tar.gz
net_monitor-35d425fe12fdde40bbdb75d1bbae1cbafe6c271e.tar.bz2
net_monitor-35d425fe12fdde40bbdb75d1bbae1cbafe6c271e.tar.xz
net_monitor-35d425fe12fdde40bbdb75d1bbae1cbafe6c271e.zip
monitoring speed
Diffstat (limited to 'plasma')
-rw-r--r--plasma/applet/contents/code/main.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/plasma/applet/contents/code/main.py b/plasma/applet/contents/code/main.py
index 744226b..4d2b44a 100644
--- a/plasma/applet/contents/code/main.py
+++ b/plasma/applet/contents/code/main.py
@@ -30,12 +30,14 @@ class NetMonitor(plasmascript.Applet):
self.layout = QGraphicsLinearLayout(Qt.Horizontal, self.applet)
+ self.monitoring = {}
self.widgets = {}
for source in self.connectToEngine():
label = Plasma.Label(self.applet)
label.setText("%s:" % source)
self.layout.addItem(label)
self.widgets[str(source)] = label
+ self.monitoring[str(source)] = {"in": 0, "out": 0}
self.applet.setLayout(self.layout)
def connectToEngine(self):
@@ -53,7 +55,21 @@ class NetMonitor(plasmascript.Applet):
print "Error: data for %s not available yet" % iface
return
widget = self.widgets[iface]
- widget.setText("%s\nIn: %d\nOut: %d" % (sourceName, data[QString("data_in")], data[QString("data_out")]))
+ data_in = int(data[QString("data_in")])
+ data_out = int(data[QString("data_out")])
+ old_data_in = self.monitoring[iface]["in"]
+ old_data_out = self.monitoring[iface]["out"]
+ if old_data_in == -1:
+ speed_in = 0
+ else:
+ speed_in = data_in - old_data_in
+ if old_data_out == -1:
+ speed_out = 0
+ else:
+ speed_out = data_out - old_data_out
+ self.monitoring[iface]["in"] = data_in
+ self.monitoring[iface]["out"] = data_out
+ widget.setText("%s\n\/: %d\n/\: %d" % (sourceName, speed_in, speed_out))
def paintInterface(self, painter, option, rect):
painter.save()