From: Brian Warner Date: Tue, 20 May 2008 19:36:55 +0000 (-0700) Subject: CLI: add put --mutable, enhance ls to show mutable vs immutable as rw/r- X-Git-Tag: allmydata-tahoe-1.1.0~100 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/frontends/%3C?a=commitdiff_plain;h=e889463f0cce965ceaa5036ac4220b7578dada3f;p=tahoe-lafs%2Ftahoe-lafs.git CLI: add put --mutable, enhance ls to show mutable vs immutable as rw/r- --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index baee26b5..84042186 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -114,6 +114,10 @@ class GetOptions(VDriveOptions): will be written to stdout.""" class PutOptions(VDriveOptions): + optFlags = [ + ("mutable", "m", "Create a mutable file instead of an immutable one."), + ] + def parseArgs(self, arg1=None, arg2=None): # cat FILE > tahoe put # create unlinked file from stdin # cat FILE > tahoe put FOO # create tahoe:FOO from stdin @@ -229,6 +233,7 @@ def put(config, stdout, stderr, stdin=sys.stdin): config.aliases, config.from_file, config.to_file, + config['mutable'], verbosity, stdin, stdout, stderr) return rc diff --git a/src/allmydata/scripts/tahoe_ls.py b/src/allmydata/scripts/tahoe_ls.py index edfcce2c..821c98c4 100644 --- a/src/allmydata/scripts/tahoe_ls.py +++ b/src/allmydata/scripts/tahoe_ls.py @@ -36,6 +36,8 @@ def list(nodeurl, aliases, where, config, stdout, stderr): childtype = child[0] ctime = child[1]["metadata"].get("ctime") mtime = child[1]["metadata"].get("mtime") + rw_uri = child[1].get("rw_uri") + ro_uri = child[1].get("ro_uri") if ctime: # match for formatting that GNU 'ls' does if (now - ctime) > 6*30*24*60*60: @@ -47,21 +49,32 @@ def list(nodeurl, aliases, where, config, stdout, stderr): else: ctime_s = "-" if childtype == "dirnode": - t = "d---------" + t0 = "d" size = "-" classify = "/" elif childtype == "filenode": - t = "----------" + t0 = "-" size = child[1]['size'] classify = "" - if "rw_uri" in child[1]: - classify = "*" # mutable + else: + t0 = "?" + size = "?" + classify = "?" + t1 = "-" + if ro_uri: + t1 = "r" + t2 = "-" + if rw_uri: + t2 = "w" + t3 = "-" + if childtype == "dirnode": + t3 = "x" - uri = child[1].get("rw_uri", child[1].get("ro_uri", "-")) + uri = rw_uri or ro_uri line = [] if config["long"]: - line.append("%s %10s %12s" % (t, size, ctime_s)) + line.append("%s %10s %12s" % (t0+t1+t2+t3, size, ctime_s)) if config["uri"]: line.append(uri) line.append(name) diff --git a/src/allmydata/scripts/tahoe_put.py b/src/allmydata/scripts/tahoe_put.py index 6288cac1..6d87b5e5 100644 --- a/src/allmydata/scripts/tahoe_put.py +++ b/src/allmydata/scripts/tahoe_put.py @@ -4,8 +4,8 @@ import urllib from allmydata.scripts.common_http import do_http from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path -def put(nodeurl, aliases, from_file, to_file, verbosity, - stdin, stdout, stderr): +def put(nodeurl, aliases, from_file, to_file, mutable, + verbosity, stdin, stdout, stderr): """ @param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose @@ -20,6 +20,8 @@ def put(nodeurl, aliases, from_file, to_file, verbosity, url += escape_path(path) else: url = nodeurl + "uri" + if mutable: + url += "?mutable=true" if from_file: infileobj = open(from_file, "rb") else: diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 50662db3..f74c06af 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1604,6 +1604,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, d.addCallback(run, "put", files[1], "subdir/tahoe-file1") # tahoe put bar tahoe:FOO d.addCallback(run, "put", files[2], "tahoe:file2") + d.addCallback(run, "put", "--mutable", files[3], "tahoe:file3") def _put_from_stdin(res, data, *args): args = nodeargs + list(args) @@ -1629,7 +1630,7 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, "tahoe:from-stdin") d.addCallback(run, "ls") - d.addCallback(_check_ls, ["tahoe-file0", "file2", "subdir", + d.addCallback(_check_ls, ["tahoe-file0", "file2", "file3", "subdir", "tahoe-file-stdin", "from-stdin"]) d.addCallback(run, "ls", "subdir") d.addCallback(_check_ls, ["tahoe-file1"]) @@ -1670,7 +1671,10 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, lines = out.split("\n") for l in lines: if "tahoe-file-stdin" in l: + self.failUnless(l.startswith("-r-- "), l) self.failUnless(" %d " % len(STDIN_DATA) in l) + if "file3" in l: + self.failUnless(l.startswith("-rw- "), l) # mutable d.addCallback(_check_ls_l) d.addCallback(run, "mv", "tahoe-file-stdin", "tahoe-moved")