Commit dcb11bc8 authored by Mario Hock's avatar Mario Hock
Browse files

curses gui: exclude "idle" from named cpu utils

(on the right side, e.g., » user: 11.10%    iowait:11.10% « )
parent 283aa714
......@@ -174,7 +174,7 @@ def display(measurement):
# user/system
#stdscr.addstr(y, LABEL_CPU_USER+6, '{0:.2%}'.format( cpu.user/100.0 ), curses.color_pair(3))
#stdscr.addstr(y, LABEL_CPU_SYSTEM+8, '{0:.2%}'.format( cpu.system/100.0 ), curses.color_pair(3))
cpu_sorted = helpers.sort_named_tuple(cpu)
cpu_sorted = helpers.sort_named_tuple(cpu, skip="idle")
t = '{0: <6}'.format( CPU_TYPE_LABELS[cpu_sorted[0][0]] )
stdscr.addstr(y, LABEL_CPU_USER, t, curses.color_pair(4))
stdscr.addstr("{:.2%}".format(cpu_sorted[0][1]/100), curses.color_pair(3))
......@@ -179,5 +179,17 @@ def get_sysinfo():
return ret
def sort_named_tuple(data):
return sorted( data._asdict().items() , key=operator.itemgetter(1), reverse=True)
def sort_named_tuple(data, skip=None):
Sort a named tuple by its values.
With |skip| a value can be specified that is excluded from the result.
d = data._asdict()
# NOTE: Possible improvement: Accept a list in skip?
if ( skip ):
del d[skip]
return sorted( d.items() , key=operator.itemgetter(1), reverse=True)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment