From: Brian Warner Date: Tue, 10 Jul 2007 22:34:55 +0000 (-0700) Subject: tahoe-ls.py: initial version of an 'ls' CLI utility X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=dec729028fe0dfb426cd0a3eee4a82c0da8a5cfe;p=tahoe-lafs%2Ftahoe-lafs.git tahoe-ls.py: initial version of an 'ls' CLI utility --- diff --git a/src/allmydata/scripts/tahoe-ls.py b/src/allmydata/scripts/tahoe-ls.py new file mode 100644 index 00000000..b5f389dc --- /dev/null +++ b/src/allmydata/scripts/tahoe-ls.py @@ -0,0 +1,37 @@ +#! /usr/bin/python + +import optparse, sys, urllib +import simplejson + +def GET(url, outf): + f = urllib.urlopen(url) + outf.write(f.read()) + +parser = optparse.OptionParser() +parser.add_option("-d", "--vdrive", dest="vdrive", default="global") +parser.add_option("-s", "--server", dest="server", default="http://tahoebs1.allmydata.com:8011") + +(options, args) = parser.parse_args() + + +url = options.server + "/vdrive/" + options.vdrive +if args: + url += "/" + args[0] +url += "?t=json" +data = urllib.urlopen(url).read() + +parsed = simplejson.loads(data) +nodetype, d = parsed +if nodetype == "dirnode": + childnames = sorted(d['children'].keys()) + for name in childnames: + child = d['children'][name] + childtype = child[0] + if childtype == "dirnode": + print "%10s %s/" % ("", name) + else: + assert childtype == "filenode" + size = child[1]['size'] + print "%10s %s" % (size, name) + +