several fixes
This commit is contained in:
+3
-3
@@ -3,8 +3,8 @@ from config import Config
|
||||
|
||||
|
||||
class AppClass:
|
||||
def __init__(self, _config: Config, testmode: bool = False) -> None:
|
||||
self.testmode = testmode
|
||||
def __init__(self, _config: Config) -> None:
|
||||
self._config = _config
|
||||
self.log = getLogger(self.__class__.__name__, loglevel=_config.loglevel.upper())
|
||||
self.log.info(f'initializing {self.__class__.__name__}')
|
||||
self.log.info(f'initializing {self.__class__.__name__}')
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
from pathlib import Path
|
||||
from logger import getLogger
|
||||
from mapping import trigger_mapping
|
||||
from config import Config
|
||||
from governor import Governor
|
||||
|
||||
|
||||
def main() -> None:
|
||||
@@ -16,6 +17,8 @@ def main() -> None:
|
||||
triggers.append(
|
||||
trigger_mapping[triggertuple.name](triggertuple.name, config)
|
||||
)
|
||||
gov = Governor(config)
|
||||
gov.cpufreq
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
+9
-5
@@ -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)
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
|
||||
cpufreq==0.3.5
|
||||
lxml==5.3.0
|
||||
|
||||
+2
-2
@@ -2,8 +2,8 @@ from app_class import AppClass
|
||||
from config import Config, TriggerTuple, MissingConfig
|
||||
|
||||
class Trigger(AppClass):
|
||||
def __init__(self, name: str, _config: Config, testmode: bool = False) -> None:
|
||||
super().__init__(_config, testmode)
|
||||
def __init__(self, name: str, _config: Config) -> None:
|
||||
super().__init__(_config)
|
||||
self.name = name
|
||||
|
||||
@property
|
||||
|
||||
+2
-2
@@ -2,6 +2,6 @@ from trigger import Trigger
|
||||
from config import Config
|
||||
|
||||
class RoonTrigger(Trigger):
|
||||
def __init__(self, name: str, _config: Config, testmode: bool = False) -> None:
|
||||
super().__init__(name, _config, testmode)
|
||||
def __init__(self, name: str, _config: Config) -> None:
|
||||
super().__init__(name, _config)
|
||||
|
||||
Reference in New Issue
Block a user