From aa09c1088ada289f662c6849674ec4f8cbd6956c Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 3 Mar 2014 17:24:15 +0100 Subject: add network MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- examples/plugin-test | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'examples/plugin-test') diff --git a/examples/plugin-test b/examples/plugin-test index 9cf449c..711ef11 100644 --- a/examples/plugin-test +++ b/examples/plugin-test @@ -17,9 +17,10 @@ from plugins.xdisplay import XDisplay from plugins.moc import MOC from plugins.cpu import CPU from plugins.clock import Clock +from plugins.network import Network -OUTPUT, HEIGHT, YPOS, TOP = 0, 24, 24, True +OUTPUT, HEIGHT, YPOS, TOP = 0, 3 * 12, 24, True clock = Clock(format = '%Y-(%m)%b-%d %T, %a w%V, %Z') @@ -179,9 +180,21 @@ def redraw(): cpu = colourise(cpu_usage(now_cpu_idle, now_cpu_total, last_cpu_idle, last_cpu_total)) cpu = 'Cpu: %s : %s' % (cpus, cpu) + gb = lambda x : x / 1024 ** 3 + net_ = Network('lo').devices + net_ = [(dev, gb(net_[dev]['rx_bytes']), gb(net_[dev]['tx_bytes'])) for dev in net_] + net_each = ['%s: %.2fGB|%.2fGB' % dev for dev in net_] + net_total = '%.2fGB|%.2fGB' % (sum([rx for _, rx, tx in net_]), sum([tx for _, rx, tx in net_])) + net = '%s : %s' % (' '.join(net_each), net_total) - text = '%s │ %s │ %s │ %s │ %s │ %s %s │ %s │ %s │ %s │ %s\n%s │ %s │ %s' - text %= (date, uptime, idle, loadavg, users, uname, xdisplay, mem, swp, shm, moc, discs, discstats, cpu) + + text = ['%s │ %s │ %s │ %s │ %s │ %s %s │ %s │ %s │ %s │ %s' + ,'%s │ %s │ %s' + ,'%s'] + text = '\n'.join(text) + text %= (date, uptime, idle, loadavg, users, uname, xdisplay, mem, swp, shm, moc, + discs, discstats, cpu, + net) bar.clear() bar.draw_coloured_text(0, 10, 0, 2, text) -- cgit v1.2.3-70-g09d2