Beispiel #1
0
def put(key, obj, remote):
    if remote:
        cloud.bucket.putf(pickle.dumps(obj), key)
    else:
        path = util.cachePath(key)
        dire = os.path.dirname(path)
        if not os.path.exists(dire):
            os.makedirs(dire)       
        pickle.dump(obj, open(path, 'w'))
Beispiel #2
0
def clear(prefix, remote):
    if (remote):
        k = cloud.call(delete_prefix, prefix)
        return cloud.result(k)
    else:
        path = util.cachePath(prefix)
        if (os.path.isdir(path)):
            sh.rmtree(path)
        elif (os.path.isfile(path)):
            os.remove(path)
Beispiel #3
0
def get(key, remote):
    if remote:
        return pickle.loads(cloud.bucket.getf(key).read())
    else:
        return pickle.load(open(util.cachePath(key), 'r'))