diff --git a/fieldpoc/config.py b/fieldpoc/config.py index 9eae96b..b2107eb 100644 --- a/fieldpoc/config.py +++ b/fieldpoc/config.py @@ -26,16 +26,19 @@ class DectConfig(ConfigBase): def check(self): return True +class ExtensionsConfig(ConfigBase): + pass + class YateConfig(ConfigBase): pass class Config: def __init__(self, c): - self._c = c self.controller = ControllerConfig(c.get("controller", {})) self.database = DatabaseConfig(c.get("database", {})) self.dect = DectConfig(c.get("dect", {})) + self.extensions = ExtensionsConfig(c.get("extensions", {})) self.yate = YateConfig(c.get("yate", {})) def check(self): diff --git a/fieldpoc/fieldpoc.py b/fieldpoc/fieldpoc.py index 434a854..02e3381 100644 --- a/fieldpoc/fieldpoc.py +++ b/fieldpoc/fieldpoc.py @@ -20,11 +20,10 @@ class FieldPOC: extensions = None temp_extensions = {} - def __init__(self, config_file_path, extensions_file_path): + def __init__(self, config_file_path): logger.info("loading configuration") self.config_file_path = pathlib.Path(config_file_path) self._load_config() - self.extensions_file_path = pathlib.Path(extensions_file_path) self._load_extensions() logger.info("initialising queues") @@ -92,4 +91,4 @@ class FieldPOC: self.config = config.Config(json.loads(self.config_file_path.read_text())) def _load_extensions(self): - self.extensions = extensions.Extensions(json.loads(self.extensions_file_path.read_text())) + self.extensions = extensions.Extensions(json.loads(pathlib.Path(self.config.extensions.file).read_text())) diff --git a/fieldpoc/run.py b/fieldpoc/run.py index 811f2cc..15b85ca 100644 --- a/fieldpoc/run.py +++ b/fieldpoc/run.py @@ -12,7 +12,6 @@ logger = logging.getLogger("fieldpoc.run") ap = argparse.ArgumentParser(prog="fieldpoc") ap.add_argument("-c", "--config", dest="config_file_path", default="fieldpoc_config.json", help="Path to the fieldpoc config file") -ap.add_argument("-e", "--extensions", dest="extensions_file_path", default="fieldpoc_extensions.json", help="Path to the fieldpoc extensions file") ap.add_argument('--init', dest="init", action='store_true') ap.add_argument('--debug', dest="debug", action='store_true') @@ -33,7 +32,7 @@ def run(): logger.info("prepared signal handling") - fp = fieldpoc.FieldPOC(config_file_path=args.config_file_path, extensions_file_path=args.extensions_file_path) + fp = fieldpoc.FieldPOC(config_file_path=args.config_file_path) if args.init: fp.init() diff --git a/fieldpoc_config.json b/fieldpoc_config.json index 709eaa3..1ee0f2e 100644 --- a/fieldpoc_config.json +++ b/fieldpoc_config.json @@ -1,4 +1,7 @@ { + "extensions": { + "file": "fieldpoc_extensions.json" + }, "controller": { "host": "127.0.0.1", "port": 9437