Commit 88f293fc15114f82ad9c51c8317fb73d0f66ec9c

Authored by Alexis Koralewski
1 parent 51f43101
Exists in dev

Update fn in obsconfig, self.fn returns only fcontext from sequence_management section

Showing 1 changed file with 28 additions and 13 deletions   Show diff stats
src/core/pyros_django/obs_config/obsconfig_class.py
... ... @@ -301,18 +301,20 @@ class OBSConfig:
301 301  
302 302  
303 303 def channel_fn_context(self, fn_context:dict):
  304 + fn = FileNames()
304 305 for context, values in fn_context.items():
305   - self.fn.fcontext_create(context, values["description"])
306   - self.fn.fcontext = context
  306 + fn.fcontext_create(context, values["description"])
  307 + fn.fcontext = context
307 308 if values.get("naming"):
308   - self.fn.naming(values["naming"])
  309 + fn.naming(values["naming"])
309 310 elif values.get("pathnaming"):
310   - self.fn.pathnaming(values["pathnaming"])
  311 + fn.pathnaming(values["pathnaming"])
311 312 root_project_path = os.environ.get("PROJECT_ROOT_PATH", os.path.join(os.getcwd(), "../../../../"))
312 313 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"]
  314 + fn.rootdir = os.path.join(data_path, values["root_dir"])
  315 + os.makedirs(fn.rootdir, exist_ok=True)
  316 + fn.extension = values["extension"]
  317 + return fn
316 318  
317 319  
318 320 def read_generic_component_and_return_attributes(self, component_name: str) -> dict:
... ... @@ -653,8 +655,9 @@ class OBSConfig:
653 655  
654 656 for channel_id in range(len(unit["TOPOLOGY"]["CHANNELS"])):
655 657 channel_fcontext = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"].get("fn_contexts")
656   - if channel_fcontext is not None:
657   - self.channel_fn_context(channel_fcontext)
  658 + if channel_fcontext is not None and type(channel_fcontext) != FileNames:
  659 + fn = self.channel_fn_context(channel_fcontext)
  660 + unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"]["fn_contexts"] = fn
658 661 channel = unit["TOPOLOGY"]["CHANNELS"][channel_id]["CHANNEL"]
659 662 channels[channel["name"]] = channel
660 663  
... ... @@ -1436,6 +1439,14 @@ class OBSConfig:
1436 1439 return channels[channel]
1437 1440 return None
1438 1441  
  1442 + def get_all_fcontext(self):
  1443 + fcontexts = {}
  1444 + fcontexts["general"] = self.fn
  1445 + channels = self.get_channels(self.unit_name)
  1446 + for channel in channels:
  1447 + fcontexts[channel] = channels[channel]["fn_contexts"]
  1448 + return fcontexts
  1449 +
1439 1450 class MissingMandatoryAgentException(Exception):
1440 1451 """
1441 1452 Exception raised when an mandatory Pyros Agent is missing in the observatory configuration.
... ... @@ -1458,10 +1469,14 @@ def main():
1458 1469 # print(config.getEditableChannelAttributes(unit_name,"OpticalChannel_up"))
1459 1470 config = OBSConfig("../../../../../PYROS_OBSERVATORY/pyros_observatory_tnc/observatory.yml")
1460 1471 unit_name = config.get_units_name()[0]
1461   - print(config.fn.fcontexts)
1462   - config.fn.fcontext = "pyros_seq"
1463   - print(config.fn)
1464   - print(config.fn.naming_keys())
  1472 + # print(config.fn.fcontexts)
  1473 + # config.fn.fcontext = "pyros_seq"
  1474 + # print(config.fn)
  1475 + # config.fn.fcontext = "pyros_seq"
  1476 + # print(config.fn)
  1477 + all_fcontexts = config.get_all_fcontext()
  1478 + #print("GENERAL FCONTEXT -- ", all_fcontexts.pop("general"))
  1479 + print(all_fcontexts["OpticalChannel_up1"].fcontexts)
1465 1480 #print(config.get_channel_of_agent("A_ImagesProcessor_up1_akz"))
1466 1481 # print(config.get_channels(unit_name))
1467 1482 # print(config.get_components_agents(unit_name))
... ...