Commit b0c81f13 authored by Piergiorgio Pancino's avatar Piergiorgio Pancino
Browse files

config/static: new function get_config_dict as a helper for reloading configuration

parent 5e396bd5
......@@ -14,6 +14,7 @@ from bliss.common import event
from bliss.common.utils import Null, autocomplete_property
from bliss.config.conductor.client import remote_open
from bliss.config.static import Node
from bliss.config.static import get_config_dict
def _find_dict(name, d):
......@@ -243,14 +244,7 @@ class BeaconObject:
f"to use apply_config of {self.name} a valid config with name has to be provied on init!"
)
with remote_open(self.config.filename) as f:
d = yaml.safe_load(f.read())
if isinstance(d, dict):
d = _find_dict(self._config_name, d)
elif isinstance(d, list):
d = _find_list(self._config_name, d)
else:
d = None
d = get_config_dict(self.config.filename, self._config_name)
if d is None:
raise RuntimeError(
......
......@@ -173,6 +173,23 @@ def get_config(base_path="", timeout=3.):
return CONFIG
def get_config_dict(fullname, node_name):
"""Loads from file the node configuration
as a dictionary
"""
with client.remote_open(fullname) as f:
d = yaml.safe_load(f.read())
if isinstance(d, dict):
d = _find_dict(node_name, d)
elif isinstance(d, list):
d = _find_list(node_name, d)
else:
d = None
return d
class Node(dict):
"""
Configuration Node. Do not instantiate this class directly.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment