Fix quicklook in case psutil.cpu_freq().max=0.0

This commit is contained in:
Ognyan Kulev 2025-12-16 17:45:42 +02:00
parent 7b22761c75
commit bd246fe966
2 changed files with 12 additions and 6 deletions

View File

@ -84,7 +84,7 @@ class CpuPercent:
self.cpu_info['cpu_hz_current'] = cpu_freq.current
else:
self.cpu_info['cpu_hz_current'] = None
if hasattr(cpu_freq, 'max'):
if hasattr(cpu_freq, 'max') and cpu_freq.max != 0.0:
self.cpu_info['cpu_hz'] = cpu_freq.max
else:
self.cpu_info['cpu_hz'] = None

View File

@ -205,12 +205,18 @@ class QuicklookPlugin(GlancesPluginModel):
if (
'cpu_hz_current' in self.stats
and self.stats['cpu_hz_current'] is not None
and 'cpu_hz' in self.stats
and self.stats['cpu_hz'] is not None
):
msg_freq = ' {:.2f}/{:.2f}GHz'.format(
self._hz_to_ghz(self.stats['cpu_hz_current']), self._hz_to_ghz(self.stats['cpu_hz'])
)
if (
'cpu_hz' in self.stats
and self.stats['cpu_hz'] is not None
):
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 = ' {:.2f}GHz'.format(
self._hz_to_ghz(self.stats['cpu_hz_current'])
)
else:
msg_freq = ''