From: Brian Warner Date: Mon, 14 Jan 2008 21:12:27 +0000 (-0700) Subject: 'tahoe dump-cap': accept http:// -prefixed URLs too X-Git-Url: https://git.rkrishnan.org/pf/content/cyclelanguage?a=commitdiff_plain;h=37b7f136ce2542c2cae938c916e88c2d5dd3f93b;p=tahoe-lafs%2Ftahoe-lafs.git 'tahoe dump-cap': accept http:// -prefixed URLs too --- diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index d2c3365a..cf08a206 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -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) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 60a7c2ec..bb1d704b 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -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())