Merge pull request #2789 from nicolargo/2788-sensortype-change-in-rest-api-breaks-compatibility-in-404

fix: plugin(sensors) - serialization bug with raw stats
This commit is contained in:
RazCrimson 2024-05-18 05:01:09 +05:30 committed by GitHub
commit 3306fa0118
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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()})