mirror of
https://github.com/nicolargo/glances.git
synced 2024-12-11 09:55:33 +03:00
Merge pull request #2832 from nicolargo/2831-j-hot-key-crashs-glances
fix: plugin (processlist) - failure on programs view
This commit is contained in:
commit
78b4518547
@ -324,18 +324,21 @@ class PluginModel(GlancesPluginModel):
|
||||
|
||||
def _get_process_curses_time(self, p, selected, args):
|
||||
"""Return process time curses"""
|
||||
cpu_times = p['cpu_times']
|
||||
try:
|
||||
# Sum user and system time
|
||||
user_system_time = p['cpu_times']['user'] + p['cpu_times']['system']
|
||||
except (OverflowError, TypeError):
|
||||
user_system_time = cpu_times['user'] + cpu_times['system']
|
||||
except (OverflowError, TypeError, KeyError):
|
||||
# Catch OverflowError on some Amazon EC2 server
|
||||
# See https://github.com/nicolargo/glances/issues/87
|
||||
# Also catch TypeError on macOS
|
||||
# See: https://github.com/nicolargo/glances/issues/622
|
||||
# Also catch KeyError (as no stats be present for processes of other users)
|
||||
# See: https://github.com/nicolargo/glances/issues/2831
|
||||
# logger.debug("Cannot get TIME+ ({})".format(e))
|
||||
msg = self.layout_header['time'].format('?')
|
||||
ret = self.curse_add_line(msg, optional=True)
|
||||
else:
|
||||
return self.curse_add_line(msg, optional=True)
|
||||
|
||||
hours, minutes, seconds = seconds_to_hms(user_system_time)
|
||||
if hours > 99:
|
||||
msg = f'{hours:<7}h'
|
||||
@ -343,12 +346,12 @@ class PluginModel(GlancesPluginModel):
|
||||
msg = f'{hours}h{minutes}:{seconds}'
|
||||
else:
|
||||
msg = f'{minutes}:{seconds}'
|
||||
|
||||
msg = self.layout_stat['time'].format(msg)
|
||||
if hours > 0:
|
||||
ret = self.curse_add_line(msg, decoration='CPU_TIME', optional=True)
|
||||
else:
|
||||
ret = self.curse_add_line(msg, optional=True)
|
||||
return ret
|
||||
return self.curse_add_line(msg, decoration='CPU_TIME', optional=True)
|
||||
|
||||
return self.curse_add_line(msg, optional=True)
|
||||
|
||||
def _get_process_curses_thread(self, p, selected, args):
|
||||
"""Return process thread curses"""
|
||||
|
Loading…
Reference in New Issue
Block a user