From 43a52391d57960c2342816eb9721269481c4c978 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 6 Dec 2024 16:41:59 +0100 Subject: [PATCH] small updates --- arguments.py | 3 ++- config.py | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/arguments.py b/arguments.py index c56410d..391fdd2 100644 --- a/arguments.py +++ b/arguments.py @@ -1,9 +1,10 @@ import argparse +from argparse import Namespace from functools import cached_property class ArgumentsParser: @cached_property - def parser(self): + def parser(self) -> Namespace: parser = argparse.ArgumentParser( prog=__file__, description='Trigger based CPU governor auto adjust program.', diff --git a/config.py b/config.py index 0099a02..abdc4bf 100644 --- a/config.py +++ b/config.py @@ -1,3 +1,4 @@ +import logging from pathlib import Path from lxml import etree from functools import cached_property @@ -24,7 +25,14 @@ class Config: @cached_property def loglevel(self) -> str: - return self.app_root.xpath('logLevel').pop().text + value = self.app_root.xpath('logLevel').pop().text.upper() + _loglevels = ", ".join(logging.getLevelNamesMapping().keys()) + if value not in logging.getLevelNamesMapping().keys(): + raise ValueError( + "logLevel can only contain one of these values: " + f"{_loglevels}" + ) + return value @cached_property def testmode(self) -> bool: