Example #1
0
class InittabManager(ServiceManager):
    def __init__(self, fileName = properties.INITTAB_FILE, **keywords):
        ServiceManager.__init__(self, **keywords)
        self.fileName = fileName
        self.lock = LockFile( fileName + '..LCK' )
        pid = self.lock.acquire()
        if pid:
            raise EResourceInUse( fileName, pid )
        self._load()
        return
    
    def __del__(self):
        self.lock.release()

    def _load(self):
        try:
            file = open(self.fileName, 'r')
        except IOError, e:
            if e.errno != errno.ENOENT:
                raise
            file = open('/dev/null', 'r')
        try:
            while 1:
                g = InittabGroup()
                g.load(file)
                # Empty group indicates EOF.
                if not g:
                    break
                self.addgroup(g)
        finally:
            file.close()
        return
Example #2
0
 def __init__(self, fileName = properties.INITTAB_FILE, **keywords):
     ServiceManager.__init__(self, **keywords)
     self.fileName = fileName
     self.lock = LockFile( fileName + '..LCK' )
     pid = self.lock.acquire()
     if pid:
         raise EResourceInUse( fileName, pid )
     self._load()
     return