fixed file not found when hwmon was not fully initialized on startup

This commit is contained in:
2019-09-15 00:43:46 +02:00
parent f8b1d87a4e
commit e4bda467bf

View File

@@ -87,8 +87,13 @@ class ThermalZone:
sysfs_f.write(str(value)) sysfs_f.write(str(value))
def read_sysfs(self, path): def read_sysfs(self, path):
with open(self.build_pwm_path(path)) as sysfs_f: try:
return sysfs_f.readline() with open(self.build_pwm_path(path)) as sysfs_f:
return sysfs_f.readline()
except FileNotFoundError as err:
logging.getLogger("pyfan").warning(
"[%s] temp source not found. Not ready yet or wrong path? (%s)" % (self.name,
err.strerror))
def set_pwm_mode(self, path, value=1): def set_pwm_mode(self, path, value=1):
self.write_sysfs(path + "_enable", value) self.write_sysfs(path + "_enable", value)