def fetch(self,args): dst = os.getcwd() dstbox = LtrSpace.boxFromCookie(dst) if args.boxname != ".": #lookup sftp://path srcbox = dstbox.space.getBox(args.boxname) srcbox.fspath = srcbox.fileurls[0][len("sftp://localhost"):] else: src = args.src.strip() srcbox = LtrSpace.boxFromCookie(src,space=dstbox.space) dstbox.fetch(srcbox,dryrun=args.dryrun)
def clone(self,args): name = args.boxname.strip() src = args.src.strip() dst = args.dst.strip() if os.path.isdir(src): srcbox = LtrSpace.boxFromCookie(src) else: space = LtrSpace().setUri(src) srcbox = space.getBox(space.boxname) dstbox = LtrBox(srcbox.space) dstbox.fspath = dst dstbox.setName(name) dstbox.create() dstbox.writeCookie()
def box(self,args): box = LtrSpace.boxFromCookie(os.getcwd()) bn= box.space.getBoxNames() def check(test,compare): if test==compare: return "* " else: return " " for boxname in bn: print check(boxname,box.id),boxname
def sync(self,args): srcuri = LtrUri().setUri(args.dburi) if args.dburi != "": srcserver = couchdb.client.Server(srcuri.dbserveruri) (src,srcuri)= (srcuri,srcuri.spaceuri.rstrip("/")) else: thisbox = LtrSpace.boxFromCookie(os.getcwd()) srcserver=thisbox.space.dbcursor src = thisbox.space srcuri = thisbox.space.spaceuri.rstrip("/") if hasattr(args,"destination"): # override boxname dst = LtrUri().setUri(args.destination) dsturi = dst.spaceuri.rstrip("/") elif hasattr(args,"boxname") and args.boxname != ".": #use dburi to lookup [args.boxname][dburi] box = srcserver[src.spacename][args.boxname] dsturi = box["couchurl"].rstrip("/") elif hasattr(args,"dst"): if args.dst == ".": dstdir = os.getcwd() else: dstdir = args.dst x= LtrSpace.boxFromCookie(dstdir) dsturi= x.space.spaceuri.rstrip("/") else: raise Exception if srcuri==dsturi: return print "ltr: sync %s %s" %(srcuri,dsturi) r = srcserver.replicate(srcuri,dsturi) import pprint if "no_changes" in r: print "Already up to date." else: #FIXME pretty print result pprint.pprint(r["history"][0])
def stat(self,args): thisbox = LtrSpace.boxFromCookie(os.getcwd()) fname = args.filename.strip() if args.boxname == ".": box = thisbox else: boxname = args.boxname box = thisbox.space.getBox(boxname) box.cwd = thisbox.cwd node = box.getNode(box.pathConv(fname)) if node != None: print node.stat(),
def ls(self,args): thisbox = LtrSpace.boxFromCookie(os.getcwd()) #args.filespec if args.boxname == ".": box = thisbox else: boxname = args.boxname box = thisbox.space.getBox(boxname) box.cwd = thisbox.cwd f = box.getNode(box.pathConv(args.filespec)) files = f.children(boxname=box.id) files = filter(lambda x: "c" in x.flags,files) filenames = map(lambda x: x.name,files) filenames.sort() print "\n".join(filenames),
def set(self,args): box = LtrSpace.boxFromCookie(os.getcwd()) key = args.key.strip() value = args.value.strip() box.space.setopt(key,value)
def show(self,args): box = LtrSpace.boxFromCookie(os.getcwd()) print box.info(),
def status(self,args): box = LtrSpace.boxFromCookie(os.getcwd()) box.commit(dryrun=True)
def commit(self,args): box = LtrSpace.boxFromCookie(os.getcwd()) box.commit(dryrun=False)