fix: plugin(sensors) - serialization bug with raw stats

This commit is contained in:
Bharath Vignesh J K 2024-05-18 04:55:05 +05:30
parent 396e78c415
commit 30ec25fa0a

View File

@ -25,6 +25,7 @@ from glances.plugins.plugin.model import GlancesPluginModel
class SensorType(str, Enum):
# Switch to `enum.StrEnum` when we only support py311+
CPU_TEMP = 'temperature_core'
FAN_SPEED = 'fan_speed'
HDD_TEMP = 'temperature_hdd'
@ -195,7 +196,7 @@ class PluginModel(GlancesPluginModel):
else:
return stats["label"]
def __set_type(self, stats, sensor_type):
def __set_type(self, stats: List[Dict[str, Any]], sensor_type: SensorType) -> List[Dict[str, Any]]:
"""Set the plugin type.
4 types of stats is possible in the sensors plugin:
@ -206,7 +207,7 @@ class PluginModel(GlancesPluginModel):
"""
for i in stats:
# Set the sensors type
i.update({'type': str(sensor_type)})
i.update({'type': sensor_type})
# also add the key name
i.update({'key': self.get_key()})