Move extensions.json file path to config file

This commit is contained in:
clerie 2022-09-02 22:03:38 +02:00
parent d72ff01372
commit 6a227b4dce
4 changed files with 10 additions and 6 deletions

View File

@ -26,16 +26,19 @@ class DectConfig(ConfigBase):
def check(self): def check(self):
return True return True
class ExtensionsConfig(ConfigBase):
pass
class YateConfig(ConfigBase): class YateConfig(ConfigBase):
pass pass
class Config: class Config:
def __init__(self, c): def __init__(self, c):
self._c = c
self.controller = ControllerConfig(c.get("controller", {})) self.controller = ControllerConfig(c.get("controller", {}))
self.database = DatabaseConfig(c.get("database", {})) self.database = DatabaseConfig(c.get("database", {}))
self.dect = DectConfig(c.get("dect", {})) self.dect = DectConfig(c.get("dect", {}))
self.extensions = ExtensionsConfig(c.get("extensions", {}))
self.yate = YateConfig(c.get("yate", {})) self.yate = YateConfig(c.get("yate", {}))
def check(self): def check(self):

View File

@ -20,11 +20,10 @@ class FieldPOC:
extensions = None extensions = None
temp_extensions = {} temp_extensions = {}
def __init__(self, config_file_path, extensions_file_path): def __init__(self, config_file_path):
logger.info("loading configuration") logger.info("loading configuration")
self.config_file_path = pathlib.Path(config_file_path) self.config_file_path = pathlib.Path(config_file_path)
self._load_config() self._load_config()
self.extensions_file_path = pathlib.Path(extensions_file_path)
self._load_extensions() self._load_extensions()
logger.info("initialising queues") logger.info("initialising queues")
@ -92,4 +91,4 @@ class FieldPOC:
self.config = config.Config(json.loads(self.config_file_path.read_text())) self.config = config.Config(json.loads(self.config_file_path.read_text()))
def _load_extensions(self): 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()))

View File

@ -12,7 +12,6 @@ logger = logging.getLogger("fieldpoc.run")
ap = argparse.ArgumentParser(prog="fieldpoc") 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("-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('--init', dest="init", action='store_true')
ap.add_argument('--debug', dest="debug", action='store_true') ap.add_argument('--debug', dest="debug", action='store_true')
@ -33,7 +32,7 @@ def run():
logger.info("prepared signal handling") 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: if args.init:
fp.init() fp.init()

View File

@ -1,4 +1,7 @@
{ {
"extensions": {
"file": "fieldpoc_extensions.json"
},
"controller": { "controller": {
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 9437 "port": 9437