Commit 1d6693bdca31ae9e14dfca3c379074ac08cdb19e
1 parent
7070ac6d
Exists in
dev
Rework Fn context in obsconfig_class
Showing
1 changed file
with
21 additions
and
16 deletions
Show diff stats
src/core/pyros_django/obs_config/obsconfig_class.py
... | ... | @@ -277,7 +277,7 @@ class OBSConfig: |
277 | 277 | config_file = yaml.safe_load(stream) |
278 | 278 | |
279 | 279 | self.DJANGO_PATH = os.environ.get( |
280 | - "DJANGO_PATH", os.path.abspath(os.path.dirname(yaml_file))) | |
280 | + "DJANGO_PATH", "..") | |
281 | 281 | self.SCHEMA_PATH = os.path.join( |
282 | 282 | self.DJANGO_PATH, "../../../config/pyros_observatory/general/schemas/") |
283 | 283 | self.CONFIG_PATH = self.obs_config_path |
... | ... | @@ -301,19 +301,19 @@ class OBSConfig: |
301 | 301 | |
302 | 302 | |
303 | 303 | def channel_fn_context(self, fn_context:dict): |
304 | - fn = FileNames() | |
305 | 304 | for context, values in fn_context.items(): |
306 | - fn.fcontext_create(context, values["description"]) | |
307 | - fn.fcontext = context | |
305 | + self.fn.fcontext_create(context, values["description"]) | |
306 | + self.fn.fcontext = context | |
308 | 307 | if values.get("naming"): |
309 | - fn.naming(values["naming"]) | |
308 | + self.fn.naming(values["naming"]) | |
310 | 309 | elif values.get("pathnaming"): |
311 | - fn.pathnaming(values["pathnaming"]) | |
310 | + self.fn.pathnaming(values["pathnaming"]) | |
312 | 311 | root_project_path = os.environ.get("PROJECT_ROOT_PATH", os.path.join(os.getcwd(), "../../../../")) |
313 | - fn.rootdir = os.path.join(root_project_path, values["root_dir"]) | |
314 | - os.makedirs(fn.rootdir, exist_ok=True) | |
315 | - fn.extension = values["extension"] | |
316 | - return fn | |
312 | + data_path = os.path.join(root_project_path, "..", "..", "DATA") | |
313 | + self.fn.rootdir = os.path.join(data_path, values["root_dir"]) | |
314 | + os.makedirs(self.fn.rootdir, exist_ok=True) | |
315 | + self.fn.extension = values["extension"] | |
316 | + | |
317 | 317 | |
318 | 318 | def read_generic_component_and_return_attributes(self, component_name: str) -> dict: |
319 | 319 | file_path = self.COMPONENT_PATH + component_name + ".yml" |
... | ... | @@ -615,11 +615,13 @@ class OBSConfig: |
615 | 615 | fn.naming(values["naming"]) |
616 | 616 | elif values.get("pathnaming"): |
617 | 617 | fn.pathnaming(values["pathnaming"]) |
618 | - root_project_path = os.environ.get("PROJECT_ROOT_PATH") | |
619 | - data_path = os.path.join(root_project_path, "..", "DATA") | |
618 | + root_project_path = os.environ.get("PROJECT_ROOT_PATH",os.path.join(os.getcwd(), "../../../../")) | |
619 | + data_path = os.path.join(root_project_path, "..", "..", "DATA") | |
620 | 620 | fn.rootdir = os.path.join(data_path, values["root_dir"]) |
621 | 621 | fn.extension = values["extension"] |
622 | 622 | self.fn = fn |
623 | + # call get_channels to add their filenames to the global filenames of obsconfig | |
624 | + self.get_channels(self.unit_name) | |
623 | 625 | |
624 | 626 | |
625 | 627 | def get_obs_name(self) -> str: |
... | ... | @@ -646,8 +648,7 @@ class OBSConfig: |
646 | 648 | for channel_id in range(len(unit["TOPOLOGY"]["CHANNELS"])): |
647 | 649 | channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"].get("fn_contexts") |
648 | 650 | if channel_fcontext is not None: |
649 | - fn = self.channel_fn_context(channel_fcontext) | |
650 | - channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"]["fn_contexts"] = fn | |
651 | + self.channel_fn_context(channel_fcontext) | |
651 | 652 | channel = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"] |
652 | 653 | channels[channel["name"]] = channel |
653 | 654 | |
... | ... | @@ -1449,9 +1450,13 @@ def main(): |
1449 | 1450 | # print(config.get_channel_groups(unit_name)) |
1450 | 1451 | # print(config.getEditableAttributesOfCapability(config.getChannelCapabilities(unit_name,"OpticalChannel_up")[0])) |
1451 | 1452 | # print(config.getEditableChannelAttributes(unit_name,"OpticalChannel_up")) |
1452 | - config = OBSConfig("../../../../../PYROS_OBSERVATORY/pyros_observatory_tnc/config/observatory_tnc.yml") | |
1453 | + config = OBSConfig("../../../../../PYROS_OBSERVATORY/pyros_observatory_tnc/observatory.yml") | |
1453 | 1454 | unit_name = config.get_units_name()[0] |
1454 | - print(config.get_channel_of_agent("A_AgentImagesProcessor_up1_akz")) | |
1455 | + print(config.fn.fcontexts) | |
1456 | + config.fn.fcontext = "pyros_seq" | |
1457 | + print(config.fn) | |
1458 | + print(config.fn.naming_keys()) | |
1459 | + #print(config.get_channel_of_agent("A_ImagesProcessor_up1_akz")) | |
1455 | 1460 | # print(config.get_channels(unit_name)) |
1456 | 1461 | # print(config.get_components_agents(unit_name)) |
1457 | 1462 | # dc = config.getDeviceControllerNameForAgent(unit_name,"mount")[0] | ... | ... |