Changeset 769b89a
- Timestamp:
- Dec 2, 2008 10:30:40 PM (16 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
- Children:
- 46a0f7a
- Parents:
- e087a7a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/federation/access.py
re087a7a r769b89a 103 103 self.read_access(config.get("access", "accessdb")) 104 104 105 self.state_filename = config.get("access", "access_state" , "")105 self.state_filename = config.get("access", "access_state") 106 106 self.read_state() 107 107 # Certs are promoted from the generic to the specific, so without a … … 304 304 305 305 def write_state(self): 306 try: 307 f = open(self.state_filename, 'w') 308 pickle.dump(self.state, f) 309 except IOError, e: 310 self.log.error("Can't write file %s: %s" % \ 311 (self.state_filename, e)) 312 except pickle.PicklingError, e: 313 self.log.error("Pickling problem: %s" % e) 314 except TypeError, e: 315 self.log.error("Pickling problem (TypeError): %s" % e) 306 if self.state_filename: 307 try: 308 f = open(self.state_filename, 'w') 309 pickle.dump(self.state, f) 310 except IOError, e: 311 self.log.error("Can't write file %s: %s" % \ 312 (self.state_filename, e)) 313 except pickle.PicklingError, e: 314 self.log.error("Pickling problem: %s" % e) 315 except TypeError, e: 316 self.log.error("Pickling problem (TypeError): %s" % e) 316 317 317 318 … … 322 323 State format is a simple pickling of the state dictionary. 323 324 """ 324 try: 325 f = open(self.state_filename, "r") 326 self.state = pickle.load(f) 327 328 self.allocation = self.state['allocation'] 329 self.projects = self.state['projects'] 330 self.keys = self.state['keys'] 331 332 self.log.debug("[read_state]: Read state from %s" % \ 333 self.state_filename) 334 except IOError, e: 335 self.log.warning("[read_state]: No saved state: Can't open %s: %s"\ 336 % (self.state_filename, e)) 337 except EOFError, e: 338 self.log.warning("[read_state]: Empty or damaged state file: %s:"\ 339 % self.state_filename) 340 except pickle.UnpicklingError, e: 341 self.log.warning(("[read_state]: No saved state: " + \ 342 "Unpickling failed: %s") % e) 343 344 # Add the ownership attributes to the authorizer. Note that the 345 # indices of the allocation dict are strings, but the attributes are 346 # fedids, so there is a conversion. 347 for k in self.allocation.keys(): 348 for o in self.allocation[k].get('owners', []): 349 self.auth.set_attribute(o, fedid(hexstr=k)) 325 if self.state_filename: 326 try: 327 f = open(self.state_filename, "r") 328 self.state = pickle.load(f) 329 330 self.allocation = self.state['allocation'] 331 self.projects = self.state['projects'] 332 self.keys = self.state['keys'] 333 334 self.log.debug("[read_state]: Read state from %s" % \ 335 self.state_filename) 336 except IOError, e: 337 self.log.warning(("[read_state]: No saved state: " +\ 338 "Can't open %s: %s") % (self.state_filename, e)) 339 except EOFError, e: 340 self.log.warning(("[read_state]: " +\ 341 "Empty or damaged state file: %s:") % \ 342 self.state_filename) 343 except pickle.UnpicklingError, e: 344 self.log.warning(("[read_state]: No saved state: " + \ 345 "Unpickling failed: %s") % e) 346 347 # Add the ownership attributes to the authorizer. Note that the 348 # indices of the allocation dict are strings, but the attributes are 349 # fedids, so there is a conversion. 350 for k in self.allocation.keys(): 351 for o in self.allocation[k].get('owners', []): 352 self.auth.set_attribute(o, fedid(hexstr=k)) 350 353 351 354
Note: See TracChangeset
for help on using the changeset viewer.