mirror of
https://github.com/nicolargo/glances.git
synced 2025-01-02 14:32:39 +03:00
Correct an issue in last commit for #1875
This commit is contained in:
parent
7e8243baf8
commit
0e9e5e9512
@ -29,7 +29,7 @@ import sys
|
||||
# Global name
|
||||
# Version should start and end with a numerical char
|
||||
# See https://packaging.python.org/specifications/core-metadata/#version
|
||||
__version__ = '3.2.0b1'
|
||||
__version__ = '3.2.0b2'
|
||||
__author__ = 'Nicolas Hennion <nicolas@nicolargo.com>'
|
||||
__license__ = 'LGPLv3'
|
||||
|
||||
|
@ -68,8 +68,12 @@ class CpuPercent(object):
|
||||
cpu_freq = psutil.cpu_freq()
|
||||
if hasattr(cpu_freq, 'current'):
|
||||
self.cpu_info['cpu_hz_current'] = cpu_freq.current
|
||||
if hasattr(cpu_freq, 'cpu_hz'):
|
||||
else:
|
||||
self.cpu_info['cpu_hz_current'] = None
|
||||
if hasattr(cpu_freq, 'max'):
|
||||
self.cpu_info['cpu_hz'] = cpu_freq.max
|
||||
else:
|
||||
self.cpu_info['cpu_hz'] = None
|
||||
# Reset timer for cache
|
||||
self.timer_cpu_info.reset(duration=self.cached_timer_cpu_info)
|
||||
return self.cpu_info
|
||||
|
@ -80,9 +80,10 @@ class Plugin(GlancesPlugin):
|
||||
stats['swap'] = None
|
||||
|
||||
# Get additional information
|
||||
stats['cpu_name'] = cpu_percent.get_info()['cpu_name']
|
||||
stats['cpu_hz_current'] = self._mhz_to_hz(cpu_percent.get_info()['cpu_hz_current'])
|
||||
stats['cpu_hz'] = self._mhz_to_hz(cpu_percent.get_info()['cpu_hz'])
|
||||
cpu_info = cpu_percent.get_info()
|
||||
stats['cpu_name'] = cpu_info['cpu_name']
|
||||
stats['cpu_hz_current'] = self._mhz_to_hz(cpu_info['cpu_hz_current']) if cpu_info['cpu_hz_current'] is not None else None
|
||||
stats['cpu_hz'] = self._mhz_to_hz(cpu_info['cpu_hz']) if cpu_info['cpu_hz'] is not None else None
|
||||
|
||||
elif self.input_method == 'snmp':
|
||||
# Not available
|
||||
@ -126,9 +127,12 @@ class Plugin(GlancesPlugin):
|
||||
|
||||
# Build the string message
|
||||
if 'cpu_name' in self.stats and 'cpu_hz_current' in self.stats and 'cpu_hz' in self.stats:
|
||||
msg_name = '{} - '.format(self.stats['cpu_name'])
|
||||
msg_freq = '{:.2f}/{:.2f}GHz'.format(self._hz_to_ghz(self.stats['cpu_hz_current']),
|
||||
self._hz_to_ghz(self.stats['cpu_hz']))
|
||||
msg_name = self.stats['cpu_name']
|
||||
if self.stats['cpu_hz_current'] and self.stats['cpu_hz']:
|
||||
msg_freq = ' - {:.2f}/{:.2f}GHz'.format(self._hz_to_ghz(self.stats['cpu_hz_current']),
|
||||
self._hz_to_ghz(self.stats['cpu_hz']))
|
||||
else:
|
||||
msg_freq = ''
|
||||
if len(msg_name + msg_freq) - 6 <= max_width:
|
||||
ret.append(self.curse_add_line(msg_name))
|
||||
ret.append(self.curse_add_line(msg_freq))
|
||||
|
Loading…
Reference in New Issue
Block a user