From deeacc6791423ee1ac7d24d0cc6eb532a768c44a Mon Sep 17 00:00:00 2001 From: Alessio Sergi Date: Wed, 22 Apr 2015 15:22:00 +0200 Subject: [PATCH] glances_processlist.py: minor fixes - Attribute 'tag_proc_time' defined outside __init__ - Catch the correct exception (OverflowError) - Display '?' if no CPU times are available --- glances/plugins/glances_processlist.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/glances/plugins/glances_processlist.py b/glances/plugins/glances_processlist.py index ac022e2c..3f49f206 100644 --- a/glances/plugins/glances_processlist.py +++ b/glances/plugins/glances_processlist.py @@ -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,