Esempio 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()
Esempio 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 ()
Esempio 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 ()
Esempio 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()
 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
Esempio 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
Esempio 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
 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
Esempio 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()
Esempio 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()
Esempio 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()
Esempio 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()
Esempio 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
Esempio 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)
Esempio 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
Esempio 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 )
Esempio n. 17
0
 def setproperty(self, path, property, value):
     path = _normpath(path)
     properties = self.__getproperties(path)
     properties[property] = value
     self.__saveproperties(path, properties)
Esempio 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)
Esempio 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()
Esempio n. 20
0
 def getproperty(self, path, property):
     return self.properties(_normpath(path))[property]
Esempio n. 21
0
 def properties(self, path):
     path = _normpath(path)
     db = self.__db()
     if db.has_key(path):
         return db[path]
     return {}
Esempio n. 22
0
 def properties(self, path):
     path=_normpath(path)
     db=self.__db()
     if db.has_key(path):
         return db[path]
     return {}
Esempio n. 23
0
 def __init__(self, propsDir):
     self.__picklepath=_normpath(propsDir)
     if not os.path.exists(self.__picklepath):
             os.makedirs(self.__picklepath)
Esempio n. 24
0
def _fixPath(root, path):
    return '%s/%s' % (root, _normpath(path))
Esempio 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)
Esempio n. 26
0
 def getproperty(self, path, property):
     return self.properties(_normpath(path))[property]
Esempio n. 27
0
 def __init__(self, propsDir):
     self.__picklepath = _normpath(propsDir)
     if not os.path.exists(self.__picklepath):
         os.makedirs(self.__picklepath)
Esempio n. 28
0
def _fixPath( root, path ):
    return '%s/%s' % (root, _normpath(path)) 
Esempio n. 29
0
 def properties(self, path):
     return self.__getproperties(_normpath(path))
Esempio n. 30
0
 def setproperty(self, path, property, value):
     path=_normpath(path)
     properties=self.__getproperties(path)
     properties[property]=value
     self.__saveproperties(path, properties)
Esempio 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()
Esempio n. 32
0
 def properties(self, path):
     return self.__getproperties(_normpath(path))
Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)