@@ -206,17 +206,6 @@ async def _create_user_dirs(username, port, sub):
206206 # - /etc/APP_NAME/user-mapping.csv
207207
208208 logger .debug ("creating user configuration directories" )
209- config_dir = f"/etc/{ APP_NAME } "
210-
211- if mapping == "FILE" :
212- mapping_file = f"{ config_dir } /user-mapping.csv"
213- if not exists (mapping_file ):
214- logger .error (
215- "%s does not exist. It should consist of two variables per user: "
216- + "username and subject claim separated by a single space." ,
217- mapping_file ,
218- )
219- return False
220209
221210 app_dir = f"/var/lib/{ APP_NAME } "
222211 if not exists (app_dir ):
@@ -724,20 +713,27 @@ async def _map_fed_to_local(sub, iss, eduperson_entitlement):
724713 """
725714 logger .debug ("For the user's identity mapping, %s method is used" , mapping )
726715 if mapping == "FILE" :
727- with open (
728- config ["Teapot" ]["mapping_file" ], "r" , encoding = "utf-8"
729- ) as mapping_file :
730- mappingreader = csv .reader (mapping_file , delimiter = " " )
716+ mapping_file = config ["Teapot" ]["mapping_file" ]
717+ if not exists (mapping_file ):
718+ logger .error (
719+ "%s does not exist. It should consist of two variables per user: "
720+ "username and subject claim separated by a single space." ,
721+ mapping_file ,
722+ )
723+ return None
724+
725+ with open (mapping_file , "r" , encoding = "utf-8" ) as mapping_file_obj :
726+ mappingreader = csv .reader (mapping_file_obj , delimiter = " " )
731727 for row in mappingreader :
732728 if row [1 ] == sub :
733729 if not row [0 ]:
734730 logger .error ("local user identity is unknown" )
735731 return None
736732 logger .info ("local user identity is %s" , row [0 ])
737733 return row [0 ]
738- else :
739- RuntimeError ("The local user for sub claim %s does not exist" , sub )
740- return None
734+
735+ raise RuntimeError (f "The local user for sub claim { sub } does not exist" )
736+
741737 elif mapping == "ALISE" :
742738 alise_instance = Alise ()
743739 local_username = alise_instance .get_local_username (sub , iss )
@@ -776,7 +772,7 @@ async def storm_webdav_state(state, condition, sub, iss, eduperson_entitlement):
776772 user = await _map_fed_to_local (sub , iss , eduperson_entitlement )
777773
778774 should_start_sw = False
779- logger .info ("Assesing the state of the storm webdav instance for user %s" , user )
775+ logger .info ("Assessing the state of the storm webdav instance for user %s" , user )
780776
781777 async with condition :
782778 if user not in state :
0 commit comments