Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
CPUnetLOG
CPUnetLOG
Commits
dcb11bc8
Commit
dcb11bc8
authored
Sep 05, 2014
by
Mario Hock
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
curses gui: exclude "idle" from named cpu utils
(on the right side, e.g., » user: 11.10% iowait:11.10% « )
parent
283aa714
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
curses_display.py
curses_display.py
+1
-1
helpers.py
helpers.py
+14
-2
No files found.
curses_display.py
View file @
dcb11bc8
...
...
@@ -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
))
...
...
helpers.py
View file @
dcb11bc8
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment