diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-03-06 14:08:51 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-03-06 14:08:51 +0100 |
commit | ce129cf1ede82971588df5e41ac2231f84a3e7b6 (patch) | |
tree | b1747dc27441c0f7d42e3b6f6e3976ddba847b76 /examples/moderate | |
parent | add todos (diff) | |
download | xpybar-ce129cf1ede82971588df5e41ac2231f84a3e7b6.tar.gz xpybar-ce129cf1ede82971588df5e41ac2231f84a3e7b6.tar.bz2 xpybar-ce129cf1ede82971588df5e41ac2231f84a3e7b6.tar.xz |
add KB/s to network speed in moderate example
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'examples/moderate')
-rw-r--r-- | examples/moderate | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/examples/moderate b/examples/moderate index 1ab25e6..f424aa0 100644 --- a/examples/moderate +++ b/examples/moderate @@ -121,8 +121,17 @@ def network(): value = 0 value /= 128 * net_tdiff return colourise(value) - net = [(dev, kbps(dev, 'rx'), kbps(dev, 'tx')) for dev in net_] - net = ['%s: %skbps↓ %skbps↑' % (dev, down, up) for dev, down, up in net] + def KBps(device, direction): + direction += '_bytes' + value = net_[device][direction] + if device in net_last: + value -= net_last[device][direction] + else: + value = 0 + value /= 1024 * net_tdiff + return value + net = [(dev, kbps(dev, 'rx'), KBps(dev, 'rx'), kbps(dev, 'tx'), KBps(dev, 'tx')) for dev in net_] + net = ['%s: %skbps(%.0fKB/s)↓ %skbps(%.0fKB/s)↑' % x for x in net] net = '%s' % ' '.join(net) net_last = net_ return net |