several fixes

This commit is contained in:
2024-12-11 08:58:29 +01:00
parent 383f8dc893
commit b875102d34
6 changed files with 22 additions and 14 deletions
+9 -5
View File
@@ -5,18 +5,22 @@ from functools import cached_property
class Governor(AppClass):
def __init__(self, _config: Config, testmode: bool = False) -> None:
super().__init__(_config, testmode)
def __init__(self, _config: Config) -> None:
super().__init__(_config)
@cached_property
def cpufreq(self) -> cpuFreq:
if self.testmode:
self.log.info("setting up governor in testmode")
return cpuFreq()
def set_governor(self, governor_name: str) -> None:
self.log.debug("setting governor to %s by using command self.cpufreq.set_governors(%s)", governor_name)
if self.testmode:
if self._config.testmode:
self.log.warning("application is running in testmode, governor not set")
return None
if governor_name not in self.cpufreq.available_governors:
self.log.error("governor %s not supported by cpu", governor_name)
return None
self.cpufreq.set_governors(governor_name)