]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
'tahoe dump-cap': accept http:// -prefixed URLs too
authorBrian Warner <warner@allmydata.com>
Mon, 14 Jan 2008 21:12:27 +0000 (14:12 -0700)
committerBrian Warner <warner@allmydata.com>
Mon, 14 Jan 2008 21:12:27 +0000 (14:12 -0700)
src/allmydata/scripts/debug.py
src/allmydata/test/test_cli.py

index d2c3365a1415ec929099f38d22b3558c1a017779..cf08a20642a702b613a50fb79cf7ea15d5a4c1ec 100644 (file)
@@ -201,9 +201,9 @@ def dump_cap(config, out=sys.stdout, err=sys.stderr):
     from allmydata import uri
     from allmydata.util.idlib import a2b
     from base64 import b32decode
+    import urlparse, urllib
 
     cap = config.cap
-    u = uri.from_string(cap)
     nodeid = None
     if config['nodeid']:
         nodeid = b32decode(config['nodeid'].upper())
@@ -217,6 +217,13 @@ def dump_cap(config, out=sys.stdout, err=sys.stderr):
         except EnvironmentError:
             pass
 
+    if cap.startswith("http"):
+        scheme, netloc, path, params, query, fragment = urlparse.urlparse(cap)
+        assert path.startswith("/uri/")
+        cap = urllib.unquote(path[len("/uri/"):])
+
+    u = uri.from_string(cap)
+
     print >>out
     dump_uri_instance(u, nodeid, secret, out, err)
 
index 60a7c2ecb6b1a8ffb885174e6df6398a51c643fe..bb1d704bc6f3d7da42671f3dcbf87ef59dcb07c1 100644 (file)
@@ -1,6 +1,7 @@
 
 from twisted.trial import unittest
 from cStringIO import StringIO
+import urllib
 
 from allmydata.util import fileutil, hashutil
 from allmydata import uri
@@ -105,6 +106,15 @@ class CLI(unittest.TestCase):
         self.failUnless("k/N: 25/100" in output)
         self.failUnless("storage index: p3w849k9whqhw6b9fkf4xjs5xc" in output)
 
+        prefixed_u = "http://127.0.0.1/uri/%s" % urllib.quote(u.to_string())
+        output = self._dump_cap(prefixed_u)
+        self.failUnless("CHK File:" in output)
+        self.failUnless("key: yyyoryarywdyqnyjbefoadeqbh" in output)
+        self.failUnless("UEB hash: hd7rwri6djiapo6itg5hcxa7ze5im7z9qwcdu8oka6qinahsbiuo" in output)
+        self.failUnless("size: 1234" in output)
+        self.failUnless("k/N: 25/100" in output)
+        self.failUnless("storage index: p3w849k9whqhw6b9fkf4xjs5xc" in output)
+
     def test_dump_cap_lit(self):
         u = uri.LiteralFileURI("this is some data")
         output = self._dump_cap(u.to_string())