Ejemplo n.º 1
0
 def delproperty(self, path, property):
     path = _normpath(path)
     self.__conn.sync()
     db = self.__db
     if db.has_key(path) and db[path].has_key(property):
         del db[path][property]
         get_transaction.commit()
Ejemplo n.º 2
0
 def properties(self, path):
     path = _normpath(path)
     self.__conn.sync()
     db = self.__db
     if db.has_key(path):
         return db[path].data.copy()
     return ()
Ejemplo n.º 3
0
 def properties(self, path):
     path=_normpath(path)
     self.__conn.sync()
     db=self.__db
     if db.has_key(path):
         return db[path].data.copy()
     return ()
Ejemplo n.º 4
0
 def delproperty(self, path, property):
     path=_normpath(path)
     self.__conn.sync()
     db=self.__db
     if db.has_key(path) and db[path].has_key(property):
         del db[path][property]
         get_transaction.commit()
Ejemplo n.º 5
0
 def getproperty(self, path, property):
     path = _normpath(path)
     property = str(property)
     db = self.__db()
     if db.has_key(path):
         pathhash = db[path]
         if pathhash.has_key(property):
             return pathhash[property]
     raise KeyError, property
Ejemplo n.º 6
0
 def getproperty(self, path, property):
     path = _normpath(path)
     self.__conn.sync()
     db = self.__db
     if db.has_key(path):
         pathhash = db[path]
         if pathhash.has_key(property):
             return pathhash[property]
     raise KeyError, property
Ejemplo n.º 7
0
 def getproperty(self, path, property):
     path=_normpath(path)
     self.__conn.sync()
     db=self.__db
     if db.has_key(path):
         pathhash=db[path]
         if pathhash.has_key(property):
             return pathhash[property]
     raise KeyError, property
Ejemplo n.º 8
0
 def getproperty(self, path, property):
     path=_normpath(path)
     property=str(property)
     db=self.__db()
     if db.has_key(path):
         pathhash=db[path]
         if pathhash.has_key(property):
             return pathhash[property]
     raise KeyError, property
Ejemplo n.º 9
0
 def setproperty(self, path, property, value):
     path = _normpath(path)
     self.__conn.sync()
     db = self.__db
     if db.has_key(path):
         pathhash = db[path]
     else:
         pathhash = PersistentMapping()
         db[path] = pathhash
     pathhash[property] = value
     get_transaction().commit()
Ejemplo n.º 10
0
 def setproperty(self, path, property, value):
     path = _normpath(path)
     property = str(property)
     db = self.__db()
     if db.has_key(path):
         pathhash = db[path]
         pathhash[property] = value
     else:
         pathhash = {property: value}
     db[path] = pathhash
     db.close()
Ejemplo n.º 11
0
 def setproperty(self, path, property, value):
     path=_normpath(path)
     self.__conn.sync()
     db=self.__db
     if db.has_key(path):
         pathhash=db[path]
     else:
         pathhash=PersistentMapping()
         db[path]=pathhash
     pathhash[property]=value
     get_transaction().commit()
Ejemplo n.º 12
0
 def setproperty(self, path, property, value):
     path=_normpath(path)
     property=str(property)
     db=self.__db()
     if db.has_key(path):
         pathhash=db[path]
         pathhash[property]=value
     else:
         pathhash={property : value}
     db[path]=pathhash
     db.close()
Ejemplo n.º 13
0
 def properties(self, path):
     path = _normpath(path)
     d, fname = self.__splitpath(path)
     comppath = os.path.join(d, self.__compname)
     try:
         db = Component.callComponent(comppath, {}, self.cache, DT_DATA)
     except VFSException:
         return {}
     if type(db) != type({}):
         raise VFSException, "corrupted or inappropriate data in %s" % comppath
     props = db.get(fname, {})
     if type(props) != type({}):
         raise VFSException, "corrupted or inappropriate data in %s" % comppath
     return props
Ejemplo n.º 14
0
def clearCache(name, arguments, matchExact=None):
    if matchExact:
        path, svr, fk = _genCachedComponentPath(name, arguments)
        _expireCacheFile(path)
    else:
        name = _normpath(name)
        md5, fullKey = cacheKey.cachekey.genCacheKey(arguments)
        if Configuration.numServers:
            names = ' '.join([
                _shellEscape("%s/%s/%s" %
                             (Configuration.componentCacheRoot, i, name))
                for i in range(Configuration.numServers)
            ])
        else:
            names = "%s/%s" % (Configuration.componentCacheRoot,
                               _shellEscape(name))

        greps = []
        for k, v in fullKey.items():
            #print "--> %r %r" % (k, v)
            greps.append(_shellQuote("%r %r" % (k, v)))

        cmd = ('%(find)s %(names)s -name "*.cache" | %(sed)s '
               "'s/.cache$/.key/' ") % {
                   'find': Configuration.findCommand,
                   'names': names,
                   'sed': Configuration.sedCommand
               }
        cmd += "|" + " | ".join([
            "%s %s -l %s" %
            (Configuration.xargsCommand, Configuration.fgrepCommand, i)
            for i in greps
        ])

        LOG('running command %s' % cmd)
        ret, out = commands.getstatusoutput(cmd)
        #LOG('code %s, out %s' % (ret, out))
        if ret:
            ERROR('Command "%s" returned %d, output:\n%s' % (cmd, ret, out))
            return

        out = [
            out[:-3] + 'cache' for i in out.split('\n')
            if len(i.strip()) and i[:6] != 'find: '
        ]

        LOG('Expiring %s' % out)
        for i in out:
            _expireCacheFile(i)
Ejemplo n.º 15
0
 def properties(self, path):
     path=_normpath(path)
     d, fname=self.__splitpath(path)
     comppath=os.path.join(d, self.__compname)
     try:
         db=Component.callComponent(comppath,
                                    {},
                                    self.cache,
                                    DT_DATA)
     except VFSException:
         return {}                
     if type(db) != type({}):
         raise VFSException, "corrupted or inappropriate data in %s" % comppath
     props=db.get(fname, {})
     if type(props) != type({}):
         raise VFSException, "corrupted or inappropriate data in %s" % comppath
     return props
Ejemplo n.º 16
0
def clearCache( name, arguments, matchExact = None ):
    if matchExact:
        path, svr, fk = _genCachedComponentPath( name, arguments )
        _expireCacheFile( path )
    else:
        name = _normpath( name )
        md5, fullKey = cacheKey.cachekey.genCacheKey( arguments )
        if Configuration.numServers:
            names = ' '.join([_shellEscape( "%s/%s/%s" % ( Configuration.componentCacheRoot,
                                                           i, name ) )
                              for i in range(Configuration.numServers) ])
        else:
            names = "%s/%s" % (Configuration.componentCacheRoot, _shellEscape( name ))

        greps = []
        for k, v in fullKey.items():
            #print "--> %r %r" % (k, v)
            greps.append( _shellQuote( "%r %r" % (k, v) ) )
                

        cmd = ('%(find)s %(names)s -name "*.cache" | %(sed)s '
               "'s/.cache$/.key/' ") % {
            'find': Configuration.findCommand,
            'names': names,
            'sed': Configuration.sedCommand
            }
        cmd += "|" + " | ".join(["%s %s -l %s" % (
            Configuration.xargsCommand, Configuration.fgrepCommand, i )
                                 for i in greps])

        LOG('running command %s' % cmd)
        ret, out = commands.getstatusoutput(cmd)
        #LOG('code %s, out %s' % (ret, out))
        if ret:
            ERROR ( 'Command "%s" returned %d, output:\n%s' % (
                cmd, ret, out ))
            return

        out = [out[:-3]+'cache' for i in out.split('\n')
               if len(i.strip()) and i[:6] != 'find: ']

        LOG('Expiring %s' % out)
        for i in out:
            _expireCacheFile( i )
Ejemplo n.º 17
0
 def setproperty(self, path, property, value):
     path = _normpath(path)
     properties = self.__getproperties(path)
     properties[property] = value
     self.__saveproperties(path, properties)
Ejemplo n.º 18
0
 def hasproperty(self, path, property):
     path = _normpath(path)
     db = self.__db()
     return db.has_key(path) and db[path].has_key(property)
Ejemplo n.º 19
0
 def delproperty(self, path, property):
     path = _normpath(path)
     db = self.__db()
     if db.has_key(path) and db[path].has_key(property):
         del db[path][property]
         db.close()
Ejemplo n.º 20
0
 def getproperty(self, path, property):
     return self.properties(_normpath(path))[property]
Ejemplo n.º 21
0
 def properties(self, path):
     path = _normpath(path)
     db = self.__db()
     if db.has_key(path):
         return db[path]
     return {}
Ejemplo n.º 22
0
 def properties(self, path):
     path=_normpath(path)
     db=self.__db()
     if db.has_key(path):
         return db[path]
     return {}
Ejemplo n.º 23
0
 def __init__(self, propsDir):
     self.__picklepath=_normpath(propsDir)
     if not os.path.exists(self.__picklepath):
             os.makedirs(self.__picklepath)
Ejemplo n.º 24
0
def _fixPath(root, path):
    return '%s/%s' % (root, _normpath(path))
Ejemplo n.º 25
0
 def hasproperty(self, path, property):
     path=_normpath(path)
     db=self.__db()
     return db.has_key(path) and db[path].has_key(property)
Ejemplo n.º 26
0
 def getproperty(self, path, property):
     return self.properties(_normpath(path))[property]
Ejemplo n.º 27
0
 def __init__(self, propsDir):
     self.__picklepath = _normpath(propsDir)
     if not os.path.exists(self.__picklepath):
         os.makedirs(self.__picklepath)
Ejemplo n.º 28
0
def _fixPath( root, path ):
    return '%s/%s' % (root, _normpath(path)) 
Ejemplo n.º 29
0
 def properties(self, path):
     return self.__getproperties(_normpath(path))
Ejemplo n.º 30
0
 def setproperty(self, path, property, value):
     path=_normpath(path)
     properties=self.__getproperties(path)
     properties[property]=value
     self.__saveproperties(path, properties)
Ejemplo n.º 31
0
 def delproperty(self, path, property):
     path=_normpath(path)
     db=self.__db()
     if db.has_key(path) and db[path].has_key(property):
         del db[path][property]
         db.close()
Ejemplo n.º 32
0
 def properties(self, path):
     return self.__getproperties(_normpath(path))
Ejemplo n.º 33
0
 def hasproperty(self, path, property):
     path=_normpath(path)
     self.__conn.sync()
     db=self.__db
     return db.has_key(path) and db[path].has_key(property)
Ejemplo n.º 34
0
 def delproperty(self, path, property):
     path = _normpath(path)
     properties = self.__getproperties(path)
     if properties.has_key(property):
         del properties[property]
     self.__saveproperties(path, properties)
Ejemplo n.º 35
0
 def delproperty(self, path, property):
     path=_normpath(path)
     properties=self.__getproperties(path)
     if properties.has_key(property):
         del properties[property]
     self.__saveproperties(path, properties)
Ejemplo n.º 36
0
 def hasproperty(self, path, property):
     path = _normpath(path)
     self.__conn.sync()
     db = self.__db
     return db.has_key(path) and db[path].has_key(property)