LogTrigger: fixed substrings output
This commit is contained in:
@@ -20,9 +20,15 @@ class TriggerString:
|
|||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def substrings(self) -> list[str]:
|
def substrings(self) -> list[str]:
|
||||||
|
_substrings = []
|
||||||
if 'substrings' in self.json_data:
|
if 'substrings' in self.json_data:
|
||||||
return self.json_data['substrings']['substring']
|
if isinstance(self.json_data['substrings']['substring'], list):
|
||||||
return []
|
_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
|
@cached_property
|
||||||
def condition(self) -> str:
|
def condition(self) -> str:
|
||||||
@@ -69,12 +75,15 @@ class LogTrigger(Trigger):
|
|||||||
self.timestamp_last_active_change = datetime.now()
|
self.timestamp_last_active_change = datetime.now()
|
||||||
if not self.active:
|
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.log.info("activating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
|
||||||
self.active = True
|
self.active = True
|
||||||
|
self.log.info("Statistics: %s", self.get_statistic_info())
|
||||||
|
|
||||||
|
|
||||||
def set_inactive(self) -> None:
|
def set_inactive(self) -> None:
|
||||||
if self.active:
|
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.log.info("deactivating trigger, log file: %s, trigger strings: %s, governor: %s", self.file, self.trigger_strings, self.governor.name)
|
||||||
self.active = False
|
self.active = False
|
||||||
|
self.log.info("Statistics: %s", self.get_statistic_info())
|
||||||
|
|
||||||
def _process_line(self, line: str) -> None:
|
def _process_line(self, line: str) -> None:
|
||||||
for trigger_string in self.trigger_strings:
|
for trigger_string in self.trigger_strings:
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "cpu_governor_auto_adjust"
|
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."
|
description = "This application has been developed to automatically change cpu governor based on certain triggers."
|
||||||
authors = [
|
authors = [
|
||||||
{ name = "Martin Reurekas", email = "martin@semrks.nl" }
|
{ name = "Martin Reurekas", email = "martin@semrks.nl" }
|
||||||
|
|||||||
Reference in New Issue
Block a user