我希望 Landscape-sysinfo 以华氏度而不是摄氏度显示 CPU 温度。有人知道如何实现吗?我假设温度读数来自 /lib/python3/dist-packages/landscape/sysinfo/temperature.py。以下是该文件的内容。提前感谢您的帮助。
从 twisted.internet.defer 导入成功
从landscape.lib.sysstats导入get_thermal_zones
温度类(对象):
def __init__(self, thermal_zone_path=None):
self._thermal_zone_path = thermal_zone_path
def register(self, sysinfo):
self._sysinfo = sysinfo
def run(self):
temperature = None
max_value = None
for zone in get_thermal_zones(self._thermal_zone_path):
if (zone.temperature_value is not None and
(max_value is None or zone.temperature_value > max_value)
):
temperature = zone.temperature
max_value = zone.temperature_value
if temperature is not None:
self._sysinfo.add_header("Temperature", temperature)
return succeed(None)
答案1
我遵循了这篇文章中的代码示例。https://ubuntuforums.org/showthread.php?t=1516573
在 Ubuntu 22.04 上,文件位置如下:
sudo nano /usr/lib/python3/dist-packages/landscape/sysinfo/temperature.py