diff --git a/tangostationcontrol/tangostationcontrol/common/configuration.py b/tangostationcontrol/tangostationcontrol/common/configuration.py index b95a21d72847f28b52cdcd86206637a4971c9b05..0c9ef868b516d9b233e5e0dac4de6656d5f4c3bf 100644 --- a/tangostationcontrol/tangostationcontrol/common/configuration.py +++ b/tangostationcontrol/tangostationcontrol/common/configuration.py @@ -31,23 +31,23 @@ def get_db_data(db, tangodb_timeout:int = 10000): # Remodel the query result device_property_result = query_to_tuples(raw_result, 3) # Populate devices dictionary from query data - devices_dict = model_devices_dict(devices_dict, device_property_result) + devices_dict = add_to_devices_dict(devices_dict, device_property_result) # Query TangoDb with built-in function for attributes data _, raw_result = dbproxy.command_inout("DbMySqlSelect", ATTRS_PROPERTIES_QUERY) # Remodel the query result attrs_property_result = query_to_tuples(raw_result, 4) # Populate devices dictionary from query data - devices_dict = model_attrs_dict(devices_dict, attrs_property_result) + devices_dict = add_to_attrs_dict(devices_dict, attrs_property_result) # Query TangoDb with built-in function for server data _, raw_result = dbproxy.command_inout("DbMySqlSelect", SERVER_QUERY) # Remodel the query result server_result = query_to_tuples(raw_result, 3) # Populate server dictionary from query data and merge it with devices dict - server_dict = model_server_dict(server_dict, devices_dict, server_result) + server_dict = add_to_server_dict(server_dict, devices_dict, server_result) return {"servers" : server_dict} -def model_devices_dict(devices_dict:dict, result:list): - """ Model a devices dictionary with the following structure: +def add_to_devices_dict(devices_dict:dict, result:list): + """ Populate a devices dictionary with the following structure: 'device_name': { 'properties' : { 'property_name': ['property_value'] } } """ for device, property, value in result: @@ -61,8 +61,8 @@ def model_devices_dict(devices_dict:dict, result:list): value_data.append(value) return devices_dict -def model_attrs_dict(devices_dict:dict, result:list): - """ Model a device dictionary with the following structure : +def add_to_attrs_dict(devices_dict:dict, result:list): + """ Populate a device dictionary with the following structure : 'device_name': { 'attribute_properties' : { 'attribute_name': {'property_name' : ['property_value'] } } } """ for device, attribute, property, value in result: @@ -78,8 +78,8 @@ def model_attrs_dict(devices_dict:dict, result:list): value_data.append(value) return devices_dict -def model_server_dict(server_dict:dict, devices_dict:dict, result:list): - """ Model the server dictionary and merge it with the devices dictionary. +def add_to_server_dict(server_dict:dict, devices_dict:dict, result:list): + """ Populate the server dictionary and merge it with the devices dictionary. At the end of the process, the dictionary will have the following structure : 'server_name' : { 'server_instance' : { 'server_class' : 'device_name': { 'properties' : { 'property_name': ['property_value'] } },