diff options
author | John Estabrook <jestabro@vyos.io> | 2022-07-31 14:33:44 -0500 |
---|---|---|
committer | John Estabrook <jestabro@vyos.io> | 2022-07-31 14:34:19 -0500 |
commit | 0e9115e34305d5a703a72557d0830e2d0ed385ac (patch) | |
tree | 435eaecec06018e105aab2665451e5b24a66a9c7 /src/services/api/graphql/recipes | |
parent | dbc8e243e13b370e74c6ab20b642c881b6377bd5 (diff) | |
download | vyos-1x-0e9115e34305d5a703a72557d0830e2d0ed385ac.tar.gz vyos-1x-0e9115e34305d5a703a72557d0830e2d0ed385ac.zip |
graphql: T4580: handle case of op-mode script name containing hyphens
Diffstat (limited to 'src/services/api/graphql/recipes')
-rw-r--r-- | src/services/api/graphql/recipes/session.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/services/api/graphql/recipes/session.py b/src/services/api/graphql/recipes/session.py index 6b580af01..ac185beb7 100644 --- a/src/services/api/graphql/recipes/session.py +++ b/src/services/api/graphql/recipes/session.py @@ -40,7 +40,7 @@ class Session: try: with open(op_mode_include_file) as f: - self._op_mode_list = f.read() + self._op_mode_list = json.loads(f.read()) except Exception: self._op_mode_list = None @@ -171,11 +171,11 @@ class Session: # handle the case that the op-mode file contains underscores: if op_mode_list is None: raise FileNotFoundError(f"No op-mode file list at '{op_mode_include_file}'") - (func_name, basename) = split_compound_op_mode_name(name, op_mode_list) - if basename == '': - raise FileNotFoundError(f"No op-mode file basename in string '{name}'") + (func_name, scriptname) = split_compound_op_mode_name(name, op_mode_list) + if scriptname == '': + raise FileNotFoundError(f"No op-mode file named in string '{name}'") - mod = load_op_mode_as_module(f'{basename}.py') + mod = load_op_mode_as_module(f'{scriptname}') func = getattr(mod, func_name) if len(list(data)) > 0: res = func(True, **data) @@ -193,11 +193,11 @@ class Session: # handle the case that the op-mode file name contains underscores: if op_mode_list is None: raise FileNotFoundError(f"No op-mode file list at '{op_mode_include_file}'") - (func_name, basename) = split_compound_op_mode_name(name, op_mode_list) - if basename == '': - raise FileNotFoundError(f"No op-mode file basename in string '{name}'") + (func_name, scriptname) = split_compound_op_mode_name(name, op_mode_list) + if scriptname == '': + raise FileNotFoundError(f"No op-mode file named in string '{name}'") - mod = load_op_mode_as_module(f'{basename}.py') + mod = load_op_mode_as_module(f'{scriptname}') func = getattr(mod, func_name) if len(list(data)) > 0: res = func(**data) |