mirror of
https://github.com/HorlogeSkynet/archey4
synced 2025-07-12 12:00:12 +02:00
[TEMPERATURE] [MODEL] Sets internal entries attributes as "private"
This commit is contained in:
archey/entries
@ -14,7 +14,7 @@ class Model:
|
||||
self.value = None
|
||||
|
||||
# The configuration object is needed to retrieve some default strings.
|
||||
self.default_strings = Configuration().get('default_strings')
|
||||
self._default_strings = Configuration().get('default_strings')
|
||||
|
||||
# Is this machine virtualized ?
|
||||
self._check_virtualization()
|
||||
@ -28,7 +28,7 @@ class Model:
|
||||
self._check_rasperry_pi()
|
||||
|
||||
if not self.value:
|
||||
self.value = self.default_strings['not_detected']
|
||||
self.value = self._default_strings['not_detected']
|
||||
|
||||
def _check_virtualization(self):
|
||||
"""
|
||||
@ -79,7 +79,7 @@ class Model:
|
||||
|
||||
# If we reach there, this _should_ be a virtual environment.
|
||||
self.value = "{0} ({1})".format(
|
||||
product_name or self.default_strings['virtual_environment'],
|
||||
product_name or self._default_strings['virtual_environment'],
|
||||
environment
|
||||
)
|
||||
|
||||
|
@ -19,20 +19,20 @@ class Temperature:
|
||||
# The configuration object is needed to retrieve some settings below.
|
||||
configuration = Configuration()
|
||||
|
||||
self.temps = []
|
||||
self._temps = []
|
||||
|
||||
# Tries `sensors` at first.
|
||||
self._run_sensors()
|
||||
|
||||
# On error (list still empty), checks for system thermal zones files.
|
||||
if not self.temps:
|
||||
if not self._temps:
|
||||
self._poll_thermal_zones()
|
||||
|
||||
# Tries `vcgencmd` for Raspberry devices.
|
||||
self._run_vcgencmd()
|
||||
|
||||
# No value could be fetched...
|
||||
if not self.temps:
|
||||
if not self._temps:
|
||||
self.value = configuration.get('default_strings')['not_detected']
|
||||
return
|
||||
|
||||
@ -42,20 +42,20 @@ class Temperature:
|
||||
|
||||
# Conversion to Fahrenheit if needed.
|
||||
if use_fahrenheit:
|
||||
for i in range(len(self.temps)):
|
||||
self.temps[i] = self._convert_to_fahrenheit(self.temps[i])
|
||||
for i in range(len(self._temps)):
|
||||
self._temps[i] = self._convert_to_fahrenheit(self._temps[i])
|
||||
|
||||
# Final average computation.
|
||||
self.value = '{0}{1}{2}'.format(
|
||||
str(round(sum(self.temps) / len(self.temps), 1)),
|
||||
str(round(sum(self._temps) / len(self._temps), 1)),
|
||||
char_before_unit,
|
||||
'F' if use_fahrenheit else 'C'
|
||||
)
|
||||
|
||||
# Multiple values ? Show the hottest.
|
||||
if len(self.temps) > 1:
|
||||
if len(self._temps) > 1:
|
||||
self.value += ' (Max. {0}{1}{2})'.format(
|
||||
str(round(max(self.temps), 1)),
|
||||
str(round(max(self._temps), 1)),
|
||||
char_before_unit,
|
||||
'F' if use_fahrenheit else 'C'
|
||||
)
|
||||
@ -86,7 +86,7 @@ class Temperature:
|
||||
# * It might be an input fan speed (from a control chip) ;
|
||||
# * Some chips/adapters might return null temperatures.
|
||||
if value != 0.0 and re.match(r"temp\d_input", name):
|
||||
self.temps.append(value)
|
||||
self._temps.append(value)
|
||||
# There is only one `temp*_input` field, let's stop the current iteration.
|
||||
break
|
||||
|
||||
@ -100,7 +100,7 @@ class Temperature:
|
||||
continue
|
||||
|
||||
if temp != 0.0:
|
||||
self.temps.append(temp)
|
||||
self._temps.append(temp)
|
||||
|
||||
def _run_vcgencmd(self):
|
||||
# Let's try to retrieve a value from the Broadcom chip on Raspberry.
|
||||
@ -112,7 +112,7 @@ class Temperature:
|
||||
except (FileNotFoundError, CalledProcessError):
|
||||
return
|
||||
|
||||
self.temps.append(
|
||||
self._temps.append(
|
||||
float(
|
||||
re.search(
|
||||
r'\d+\.\d+',
|
||||
|
Reference in New Issue
Block a user