]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
CLI ls: add --readonly-uri to display readonly URIs for all children
authorBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 19:49:11 +0000 (12:49 -0700)
committerBrian Warner <warner@allmydata.com>
Tue, 20 May 2008 19:49:11 +0000 (12:49 -0700)
src/allmydata/scripts/cli.py
src/allmydata/scripts/tahoe_ls.py
src/allmydata/test/test_system.py

index 84042186b91ab046672a7529144a0f7eaf4b9364..56a1b88e6ca639a42e8c1ad311cd49c088eeb9f7 100644 (file)
@@ -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"),
         ]
index 821c98c4595884080736f09906015a91716c1e58..02dc87028d23520c41226bd6d74d6ab28ce7a319 100644 (file)
@@ -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
index f74c06af360a4c2fbaef1ebae4092c3a67dcfabd..4260530f079d35abac95ef5f868319916c77344b 100644 (file)
@@ -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"])