提交 deeacc67 编写于 作者: A Alessio Sergi

glances_processlist.py: minor fixes

- Attribute 'tag_proc_time' defined outside __init__
- Catch the correct exception (OverflowError)
- Display '?' if no CPU times are available
上级 8d1a741e
......@@ -58,6 +58,9 @@ class Plugin(GlancesPlugin):
# We want to display the stat in the curse interface
self.display_curse = True
# Trying to display proc time
self.tag_proc_time = True
# Note: 'glances_processes' is already init in the glances_processes.py script
def get_key(self):
......@@ -237,7 +240,7 @@ class Plugin(GlancesPlugin):
if self.tag_proc_time:
try:
delta = timedelta(seconds=sum(p['cpu_times']))
except Exception:
except OverflowError:
# Catched on some Amazon EC2 server
# See https://github.com/nicolargo/glances/issues/87
self.tag_proc_time = False
......@@ -248,7 +251,7 @@ class Plugin(GlancesPlugin):
else:
msg = '{0}:{1}.{2}'.format(minutes, seconds, microseconds)
else:
msg = ' '
msg = '?'
msg = '{0:>10}'.format(msg)
ret.append(self.curse_add_line(msg, optional=True))
# IO read/write
......@@ -409,9 +412,6 @@ class Plugin(GlancesPlugin):
msg = ' {0:8}'.format(_("Command"))
ret.append(self.curse_add_line(msg))
# Trying to display proc time
self.tag_proc_time = True
if glances_processes.is_tree_enabled():
ret.extend(self.get_process_tree_curses_data(
self.sort_stats(process_sort_key), args, first_level=True,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册