From: Brian Warner Date: Tue, 20 May 2008 19:49:11 +0000 (-0700) Subject: CLI ls: add --readonly-uri to display readonly URIs for all children X-Git-Tag: allmydata-tahoe-1.1.0~99 X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=a8ed3208ba2be98cb02d9efc82f43c0867c7a289;p=tahoe-lafs%2Ftahoe-lafs.git CLI ls: add --readonly-uri to display readonly URIs for all children --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 84042186..56a1b88e 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -85,7 +85,8 @@ class AddAliasOptions(VDriveOptions): class ListOptions(VDriveOptions): optFlags = [ ("long", "l", "Use long format: show file sizes, and timestamps"), - ("uri", "u", "Show file URIs"), + ("uri", "u", "Show file/directory URIs"), + ("readonly-uri", None, "Show readonly file/directory URIs"), ("classify", "F", "Append '/' to directory names, and '*' to mutable"), ("json", None, "Show the raw JSON output"), ] diff --git a/src/allmydata/scripts/tahoe_ls.py b/src/allmydata/scripts/tahoe_ls.py index 821c98c4..02dc8702 100644 --- a/src/allmydata/scripts/tahoe_ls.py +++ b/src/allmydata/scripts/tahoe_ls.py @@ -56,6 +56,8 @@ def list(nodeurl, aliases, where, config, stdout, stderr): t0 = "-" size = child[1]['size'] classify = "" + if rw_uri: + classify = "*" else: t0 = "?" size = "?" @@ -77,6 +79,8 @@ def list(nodeurl, aliases, where, config, stdout, stderr): line.append("%s %10s %12s" % (t0+t1+t2+t3, size, ctime_s)) if config["uri"]: line.append(uri) + if config["readonly-uri"]: + line.append(ro_uri or "-") line.append(name) if config["classify"]: line[-1] += classify diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index f74c06af..4260530f 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1605,6 +1605,9 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, # tahoe put bar tahoe:FOO d.addCallback(run, "put", files[2], "tahoe:file2") d.addCallback(run, "put", "--mutable", files[3], "tahoe:file3") + def _check_put_mutable((out,err)): + self._mutable_file3_uri = out.strip() + d.addCallback(_check_put_mutable) def _put_from_stdin(res, data, *args): args = nodeargs + list(args) @@ -1677,6 +1680,26 @@ class SystemTest(testutil.SignalMixin, testutil.PollMixin, testutil.StallMixin, self.failUnless(l.startswith("-rw- "), l) # mutable d.addCallback(_check_ls_l) + d.addCallback(run, "ls", "--uri") + def _check_ls_uri((out,err)): + lines = out.split("\n") + for l in lines: + if "file3" in l: + self.failUnless(self._mutable_file3_uri in l) + d.addCallback(_check_ls_uri) + + d.addCallback(run, "ls", "--readonly-uri") + def _check_ls_rouri((out,err)): + lines = out.split("\n") + for l in lines: + if "file3" in l: + rw_uri = self._mutable_file3_uri + u = uri.from_string_mutable_filenode(rw_uri) + ro_uri = u.get_readonly().to_string() + self.failUnless(ro_uri in l) + d.addCallback(_check_ls_rouri) + + d.addCallback(run, "mv", "tahoe-file-stdin", "tahoe-moved") d.addCallback(run, "ls") d.addCallback(_check_ls, ["tahoe-moved"], ["tahoe-file-stdin"])