@@ -215,7 +215,7 @@ class IocInfo:
215215 host : str
216216 hostname : str
217217 ioc_name : str
218- ioc_IP : str
218+ ioc_ip : str
219219 owner : str
220220 time : str
221221 port : int
@@ -271,7 +271,7 @@ def __init__(self, name: Optional[str], conf: ConfigAdapter):
271271 self .cf_config = CFConfig .loads (conf )
272272 self .name = name # Override name from service.Service
273273 self .channel_ioc_ids : Dict [str , List [str ]] = defaultdict (list )
274- self .iocs : Dict [str , IocInfo ] = dict ()
274+ self .iocs : Dict [str , IocInfo ] = {}
275275 self .client : Optional [ChannelFinderClient ] = None
276276 self .current_time : Callable [[Optional [str ]], str ] = get_current_time
277277 self .lock : DeferredLock = DeferredLock ()
@@ -465,7 +465,7 @@ def transaction_to_record_infos(self, ioc_info: IocInfo, transaction: CommitTran
465465 for record_id , (record_infos_to_add ) in transaction .record_infos_to_add .items ():
466466 # find intersection of these sets
467467 if record_id not in record_infos :
468- _log .warning ("IOC: %s: PV not found for recinfo with RID: {record_id} " , ioc_info , record_id )
468+ _log .warning ("IOC: %s: PV not found for recinfo with RID: %s " , ioc_info , record_id )
469469 continue
470470 recinfo_wl = [p for p in self .record_property_names_list if p in record_infos_to_add .keys ()]
471471 if recinfo_wl :
@@ -595,7 +595,7 @@ def _commit_with_thread(self, transaction: CommitTransaction):
595595 host = host ,
596596 hostname = transaction .client_infos .get ("HOSTNAME" ) or host ,
597597 ioc_name = ioc_name ,
598- ioc_IP = host ,
598+ ioc_ip = host ,
599599 owner = owner ,
600600 time = self .current_time (self .cf_config .timezone ),
601601 port = port ,
@@ -612,25 +612,25 @@ def _commit_with_thread(self, transaction: CommitTransaction):
612612 if not poll_success :
613613 raise defer .CancelledError (f"Failed to commit transaction after polling retries: { transaction } " )
614614
615- def remove_channel (self , recordName : str , iocid : str ) -> None :
615+ def remove_channel (self , record_name : str , iocid : str ) -> None :
616616 """Remove channel from self.iocs and self.channel_ioc_ids.
617617
618618 Args:
619- recordName : The name of the record to remove.
619+ record_name : The name of the record to remove.
620620 iocid: The IOC ID of the record to remove from.
621621 """
622- self .channel_ioc_ids [recordName ].remove (iocid )
622+ self .channel_ioc_ids [record_name ].remove (iocid )
623623 if iocid not in self .iocs :
624- if len (self .channel_ioc_ids [recordName ]) == 0 :
625- del self .channel_ioc_ids [recordName ]
624+ if len (self .channel_ioc_ids [record_name ]) == 0 :
625+ del self .channel_ioc_ids [record_name ]
626626 return
627627 self .iocs [iocid ].channelcount -= 1
628628 if self .iocs [iocid ].channelcount <= 0 :
629629 if self .iocs [iocid ].channelcount < 0 :
630630 _log .error ("Channel count negative: %s" , iocid )
631631 self .iocs .pop (iocid )
632- if len (self .channel_ioc_ids [recordName ]) == 0 :
633- del self .channel_ioc_ids [recordName ]
632+ if len (self .channel_ioc_ids [record_name ]) == 0 :
633+ del self .channel_ioc_ids [record_name ]
634634
635635 def clean_service (self ) -> None :
636636 """Marks all channels belonging to this recceiver (as found by the recceiver id) as 'Inactive'."""
@@ -738,7 +738,7 @@ def handle_channel_is_old(
738738 if cf_config .alias_enabled :
739739 if cf_channel .name in record_info_by_name :
740740 for alias_name in record_info_by_name [cf_channel .name ].aliases :
741- # TODO Remove? This code couldn't have been working... .
741+ # Legacy alias handling retained to avoid changing runtime behavior .
742742 alias_channel = CFChannel (alias_name , "" , [])
743743 if alias_name in channel_ioc_ids :
744744 last_alias_ioc_id = channel_ioc_ids [alias_name ][- 1 ]
@@ -1035,23 +1035,22 @@ def update_existing_channel_diff_iocid(
10351035 channels .append (existing_channel )
10361036 _log .debug ("Add existing channel with different IOC: %s" , existing_channel )
10371037 # in case, alias exists, update their properties too
1038- if cf_config .alias_enabled :
1039- if channel_name in record_info_by_name :
1040- alias_properties = [CFProperty .alias (ioc_info .owner , channel_name )]
1041- for p in new_properties :
1042- alias_properties .append (p )
1043- for alias_name in record_info_by_name [channel_name ].aliases :
1044- if alias_name in existing_channels :
1045- ach = existing_channels [alias_name ]
1046- ach .properties = __merge_property_lists (
1047- alias_properties ,
1048- ach ,
1049- managed_properties ,
1050- )
1051- channels .append (ach )
1052- else :
1053- channels .append (CFChannel (alias_name , ioc_info .owner , alias_properties ))
1054- _log .debug ("Add existing alias %s of %s with different IOC from %s" , alias_name , channel_name , iocid )
1038+ if cf_config .alias_enabled and channel_name in record_info_by_name :
1039+ alias_properties = [CFProperty .alias (ioc_info .owner , channel_name )]
1040+ for p in new_properties :
1041+ alias_properties .append (p )
1042+ for alias_name in record_info_by_name [channel_name ].aliases :
1043+ if alias_name in existing_channels :
1044+ ach = existing_channels [alias_name ]
1045+ ach .properties = __merge_property_lists (
1046+ alias_properties ,
1047+ ach ,
1048+ managed_properties ,
1049+ )
1050+ channels .append (ach )
1051+ else :
1052+ channels .append (CFChannel (alias_name , ioc_info .owner , alias_properties ))
1053+ _log .debug ("Add existing alias %s of %s with different IOC from %s" , alias_name , channel_name , iocid )
10551054
10561055
10571056def create_new_channel (
@@ -1078,14 +1077,13 @@ def create_new_channel(
10781077
10791078 channels .append (CFChannel (channel_name , ioc_info .owner , new_properties ))
10801079 _log .debug ("Add new channel: %s" , channel_name )
1081- if cf_config .alias_enabled :
1082- if channel_name in record_info_by_name :
1083- alias_properties = [CFProperty .alias (ioc_info .owner , channel_name )]
1084- for p in new_properties :
1085- alias_properties .append (p )
1086- for alias in record_info_by_name [channel_name ].aliases :
1087- channels .append (CFChannel (alias , ioc_info .owner , alias_properties ))
1088- _log .debug ("Add new alias: %s from %s" , alias , channel_name )
1080+ if cf_config .alias_enabled and channel_name in record_info_by_name :
1081+ alias_properties = [CFProperty .alias (ioc_info .owner , channel_name )]
1082+ for p in new_properties :
1083+ alias_properties .append (p )
1084+ for alias in record_info_by_name [channel_name ].aliases :
1085+ channels .append (CFChannel (alias , ioc_info .owner , alias_properties ))
1086+ _log .debug ("Add new alias: %s from %s" , alias , channel_name )
10891087
10901088
10911089class IOCMissingInfoError (Exception ):
@@ -1141,7 +1139,7 @@ def _update_channelfinder(
11411139 for ch in client .findByArgs (prepare_find_args (cf_config = cf_config , args = [("iocid" , iocid )]))
11421140 ]
11431141
1144- if old_channels is not None :
1142+ if old_channels :
11451143 handle_channels (
11461144 old_channels ,
11471145 new_channels ,
@@ -1169,7 +1167,7 @@ def _update_channelfinder(
11691167 recceiverid ,
11701168 ioc_info .hostname ,
11711169 ioc_info .ioc_name ,
1172- ioc_info .ioc_IP ,
1170+ ioc_info .ioc_ip ,
11731171 ioc_info .ioc_id ,
11741172 )
11751173 if (
@@ -1221,26 +1219,26 @@ def cf_set_chunked(client: ChannelFinderClient, channels: List[CFChannel], chunk
12211219
12221220
12231221def create_ioc_properties (
1224- owner : str , iocTime : str , recceiverid : str , hostName : str , iocName : str , iocIP : str , iocid : str
1222+ owner : str , ioc_time : str , recceiverid : str , host_name : str , ioc_name : str , ioc_ip : str , iocid : str
12251223) -> List [CFProperty ]:
12261224 """Create the properties from an IOC.
12271225
12281226 Args:
12291227 owner: The owner of the properties.
1230- iocTime : The time of the properties.
1228+ ioc_time : The time of the properties.
12311229 recceiverid: The recceiver ID of the properties.
1232- hostName : The host name of the properties.
1233- iocName : The IOC name of the properties.
1234- iocIP : The IOC IP of the properties.
1230+ host_name : The host name of the properties.
1231+ ioc_name : The IOC name of the properties.
1232+ ioc_ip : The IOC IP of the properties.
12351233 iocid: The IOC ID of the properties.
12361234 """
12371235 return [
1238- CFProperty (CFPropertyName .HOSTNAME .value , owner , hostName ),
1239- CFProperty (CFPropertyName .IOC_NAME .value , owner , iocName ),
1236+ CFProperty (CFPropertyName .HOSTNAME .value , owner , host_name ),
1237+ CFProperty (CFPropertyName .IOC_NAME .value , owner , ioc_name ),
12401238 CFProperty (CFPropertyName .IOC_ID .value , owner , iocid ),
1241- CFProperty (CFPropertyName .IOC_IP .value , owner , iocIP ),
1239+ CFProperty (CFPropertyName .IOC_IP .value , owner , ioc_ip ),
12421240 CFProperty .active (owner ),
1243- CFProperty .time (owner , iocTime ),
1241+ CFProperty .time (owner , ioc_time ),
12441242 CFProperty (CFPropertyName .RECCEIVER_ID .value , owner , recceiverid ),
12451243 ]
12461244
@@ -1265,7 +1263,7 @@ def create_default_properties(
12651263 recceiverid ,
12661264 last_ioc_info .hostname ,
12671265 last_ioc_info .ioc_name ,
1268- last_ioc_info .ioc_IP ,
1266+ last_ioc_info .ioc_ip ,
12691267 last_ioc_info .ioc_id ,
12701268 )
12711269
@@ -1302,13 +1300,12 @@ def get_current_time(timezone: Optional[str] = None) -> str:
13021300 return str (datetime .datetime .now ())
13031301
13041302
1305- def prepare_find_args (cf_config : CFConfig , args , size = 0 ) -> List [Tuple [str , str ]]:
1303+ def prepare_find_args (cf_config : CFConfig , args ) -> List [Tuple [str , str ]]:
13061304 """Prepare the find arguments.
13071305
13081306 Args:
13091307 cf_config: The configuration.
13101308 args: The arguments.
1311- size: The size.
13121309 """
13131310 size_limit = int (cf_config .cf_query_limit )
13141311 if size_limit > 0 :
0 commit comments