def stats(host): conn = cache.connect(host=host) st = conn.stats() for k in st: v = st[k] if isinstance(v, str): print '%s = "%s"' % (k, v) else: print '%s = %s' % (k, v)
def get(lfn, path, symlink): if not os.path.isabs(path): path = os.path.abspath(path) if os.path.exists(path): sys.stderr.write("Path %s already exists. Removing." % path) os.unlink(path) conn = cache.connect() conn.get(lfn, path, symlink)
def put(path, lfn, smart_move): # If the path doesn't exist, then skip it if not os.path.exists(path): sys.stderr.write("Path %s does not exist\n" % path) return if not os.path.isabs(path): path = os.path.abspath(path) conn = cache.connect() conn.put(path, lfn, smart_move)
def multiput(stream, symlink): pairs = [] for l in stream.readlines(): l = l.strip() if len(l)==0 or l.startswith('#'): continue path, lfn = l.split() if not os.path.exists(path): sys.stderr.write("Path %s does not exists\n" % path) continue if not os.path.isabs(path): path = os.path.abspath(path) pairs.append([path, lfn]) conn = cache.connect() conn.multiput(pairs, symlink)
def multiget(stream, symlink): pairs = [] for l in stream.readlines(): l = l.strip() if len(l)==0 or l.startswith('#'): continue lfn, path = l.split() if not os.path.isabs(path): path = os.path.abspath(path) if os.path.exists(path): sys.stderr.write("Path %s already exists. Removing." % path) os.unlink(path) pairs.append([lfn, path]) conn = cache.connect() conn.multiget(pairs, symlink)
def rls_clear(): conn = cache.connect() conn.rls_clear()
def clear(host): conn = cache.connect(host=host) conn.clear()
def get_bloom_filter(m, k): conn = cache.connect() bloom = conn.get_bloom_filter(m, k) for i in range(0, len(bloom)): print 'BloomFilter%d = "%s"' % (i, bloom[i])
def rls_delete(lfn, pfn): conn = cache.connect() conn.rls_delete(lfn, pfn)
def rls_lookup(lfn): conn = cache.connect() pfns = conn.rls_lookup(lfn) for pfn in pfns: print pfn
def rls_add(lfn, pfn): conn = cache.connect() conn.rls_add(lfn, pfn)
def ls(host): conn = cache.connect(host=host) results = conn.list() for rec in results: print rec['lfn'], rec['status']
def remove(lfn, force): conn = cache.connect() conn.remove(lfn, force)