30 lines
938 B
Python
30 lines
938 B
Python
from app_class import AppClass
|
|
from config import Config
|
|
from cpufreq import cpuFreq
|
|
from functools import cached_property
|
|
|
|
|
|
class Governor(AppClass):
|
|
def __init__(self, _config: Config) -> None:
|
|
super().__init__(_config)
|
|
|
|
@cached_property
|
|
def _cpufreq(self) -> cpuFreq:
|
|
return cpuFreq()
|
|
|
|
def set_governor(self, governor_name: str) -> None:
|
|
self.log.debug(
|
|
"setting cpu governor to %s by using command self._cpufreq.set_governors(%s)",
|
|
governor_name, governor_name
|
|
)
|
|
|
|
if self._config.testmode:
|
|
self.log.warning("application is running in testmode, cpu 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)
|