Changeset d064566 for fedd/federation


Ignore:
Timestamp:
Jul 7, 2012 5:39:23 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, master
Children:
e062282
Parents:
d58ee5e
Message:

Updates, initial checkin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/authorizer.py

    rd58ee5e rd064566  
    2121import os, os.path
    2222import re
     23import fcntl
    2324
    2425class authorizer_base:
     
    208209    class bad_cert_error(RuntimeError): pass
    209210
    210     def __init__(self, certs=None, me=None, key=None, load=None, save=None):
     211    def __init__(self, certs=None, me=None, key=None, load=None, save=None,
     212            update=None):
    211213        self.creddy_id = None
    212214        self.globals = set()
     
    215217        self.save_dir = load or save
    216218        self.local_files = False
     219        self.update_dir = os.path.abspath(update)
    217220        if self.save_dir:
    218221            self.save_dir = os.path.abspath(self.save_dir)
     
    648651        return found
    649652
     653    def update(self):
     654        rv = False
     655        if update_dir is None: return True
     656        lf = None
     657        files = []
     658        try:
     659            lf = open('%s/lock' % self.update_dir, 'r')
     660        except EnvironmentError, e:
     661            return rv
     662        try:
     663            fcntl.flock(lf, fcntl.LOCK_EX)
     664            files = os.listdir(update_dir)
     665            rv = self.import_credentials(file_list=files)
     666            try:
     667                for fn in files:
     668                    os.remove(fn)
     669            except EnvironmentError, e:
     670                # failure to clear the update directory is no biggie
     671                pass
     672            rv = True
     673        finally:
     674            fcntl.flock(fl, fcntl.LOCK_UN)
     675        return rv
     676
     677           
     678       
     679
    650680    def __str__(self):
    651681
Note: See TracChangeset for help on using the changeset viewer.