[wiki] [sites] wiki updated
changeset: 676:eed71f80b7f1
tag: tip
user: Wojciech Gac <wgac_AT_wp.pl>
date: Tue Jan 18 16:16:57 2011 +0100
files: wmii.suckless.org/code_snippets/python/memory_usage_indicator.md
description:
Simplified the memory indicator by abstracting redundant function calls.
diff -r cdf0e6f07e06 -r eed71f80b7f1 wmii.suckless.org/code_snippets/python/memory_usage_indicator.md
--- a/wmii.suckless.org/code_snippets/python/memory_usage_indicator.md Tue Jan 18 15:40:24 2011 +0300
+++ b/wmii.suckless.org/code_snippets/python/memory_usage_indicator.md Tue Jan 18 16:16:57 2011 +0100
_AT_@ -16,11 +16,11 @@
_AT_defmonitor
def fmem(self):
inp = subprocess.Popen(['free'], shell = False, stdout = subprocess.PIPE)
- out = inp.communicate()
- ram = int(out[0].splitlines()[2].split()[2])/1024
- maxram = int(out[0].splitlines()[1].split()[1])/1024
- swap = int(out[0].splitlines()[3].split()[2])/1024
- maxswap = int(out[0].splitlines()[3].split()[1])/1024
+ out = inp.communicate()[0].splitlines()
+ ram = int(out[2].split()[2])/1024
+ maxram = int(out[1].split()[1])/1024
+ swap = int(out[3].split()[2])/1024
+ maxswap = int(out[3].split()[1])/1024
return wmii.cache['normcolors'], 'RAM: ' + str(ram) + '/' + str(maxram) +\
' MB' + ' | SWAP: ' + str(swap) + '/' + str(maxswap) + ' MB'
Received on Tue Jan 18 2011 - 16:17:22 CET
This archive was generated by hypermail 2.3.0
: Thu Sep 13 2012 - 19:31:36 CEST