diff --git a/src/core/pyros_django/obs_config/obsconfig_class.py b/src/core/pyros_django/obs_config/obsconfig_class.py index cf48990..a768b3d 100644 --- a/src/core/pyros_django/obs_config/obsconfig_class.py +++ b/src/core/pyros_django/obs_config/obsconfig_class.py @@ -301,18 +301,20 @@ class OBSConfig: def channel_fn_context(self, fn_context:dict): + fn = FileNames() for context, values in fn_context.items(): - self.fn.fcontext_create(context, values["description"]) - self.fn.fcontext = context + fn.fcontext_create(context, values["description"]) + fn.fcontext = context if values.get("naming"): - self.fn.naming(values["naming"]) + fn.naming(values["naming"]) elif values.get("pathnaming"): - self.fn.pathnaming(values["pathnaming"]) + fn.pathnaming(values["pathnaming"]) root_project_path = os.environ.get("PROJECT_ROOT_PATH", os.path.join(os.getcwd(), "../../../../")) data_path = os.path.join(root_project_path, "..", "DATA") - self.fn.rootdir = os.path.join(data_path, values["root_dir"]) - os.makedirs(self.fn.rootdir, exist_ok=True) - self.fn.extension = values["extension"] + fn.rootdir = os.path.join(data_path, values["root_dir"]) + os.makedirs(fn.rootdir, exist_ok=True) + fn.extension = values["extension"] + return fn def read_generic_component_and_return_attributes(self, component_name: str) -> dict: @@ -653,8 +655,9 @@ class OBSConfig: for channel_id in range(len(unit["TOPOLOGY"]["CHANNELS"])): channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"].get("fn_contexts") - if channel_fcontext is not None: - self.channel_fn_context(channel_fcontext) + if channel_fcontext is not None and type(channel_fcontext) != FileNames: + fn = self.channel_fn_context(channel_fcontext) + unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"]["fn_contexts"] = fn channel = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"] channels[channel["name"]] = channel @@ -1436,6 +1439,14 @@ class OBSConfig: return channels[channel] return None + def get_all_fcontext(self): + fcontexts = {} + fcontexts["general"] = self.fn + channels = self.get_channels(self.unit_name) + for channel in channels: + fcontexts[channel] = channels[channel]["fn_contexts"] + return fcontexts + class MissingMandatoryAgentException(Exception): """ Exception raised when an mandatory Pyros Agent is missing in the observatory configuration. @@ -1458,10 +1469,14 @@ def main(): # print(config.getEditableChannelAttributes(unit_name,"OpticalChannel_up")) config = OBSConfig("../../../../../PYROS_OBSERVATORY/pyros_observatory_tnc/observatory.yml") unit_name = config.get_units_name()[0] - print(config.fn.fcontexts) - config.fn.fcontext = "pyros_seq" - print(config.fn) - print(config.fn.naming_keys()) + # print(config.fn.fcontexts) + # config.fn.fcontext = "pyros_seq" + # print(config.fn) + # config.fn.fcontext = "pyros_seq" + # print(config.fn) + all_fcontexts = config.get_all_fcontext() + #print("GENERAL FCONTEXT -- ", all_fcontexts.pop("general")) + print(all_fcontexts["OpticalChannel_up1"].fcontexts) #print(config.get_channel_of_agent("A_ImagesProcessor_up1_akz")) # print(config.get_channels(unit_name)) # print(config.get_components_agents(unit_name)) -- libgit2 0.21.2