LogTrigger: fixed substrings output

This commit is contained in:
2025-03-29 16:37:05 +01:00
parent ed8aef1e40
commit 798d25e75c
2 changed files with 14 additions and 5 deletions
+11 -2
View File
@@ -20,9 +20,15 @@ class TriggerString:
@cached_property
def substrings(self) -> list[str]:
_substrings = []
if 'substrings' in self.json_data:
return self.json_data['substrings']['substring']
return []
if isinstance(self.json_data['substrings']['substring'], list):
_substrings.extend(self.json_data['substrings'])
elif isinstance(self.json_data['substrings']['substring'], str):
_substrings.append(self.json_data['substrings']['substring'])
else:
raise ValueError("substrings must be a list or a string")
return _substrings
@cached_property
def condition(self) -> str:
@@ -70,11 +76,14 @@ class LogTrigger(Trigger):
if not self.active:
self.log.info("activating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
self.active = True
self.log.info("Statistics: %s", self.get_statistic_info())
def set_inactive(self) -> None:
if self.active:
self.log.info("deactivating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
self.active = False
self.log.info("Statistics: %s", self.get_statistic_info())
def _process_line(self, line: str) -> None:
for trigger_string in self.trigger_strings:
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "cpu_governor_auto_adjust"
version = "0.2.5"
version = "0.2.9"
description = "This application has been developed to automatically change cpu governor based on certain triggers."
authors = [
{ name = "Martin Reurekas", email = "martin@semrks.nl" }