From: Brian Warner Date: Sat, 24 Jan 2009 00:00:02 +0000 (-0700) Subject: #509: remove non-streaming 'tahoe manifest' CLI form X-Git-Tag: allmydata-tahoe-1.3.0~149 X-Git-Url: https://git.rkrishnan.org/vdrive/quickstart.html?a=commitdiff_plain;h=1de4110b351b995c69e09ef58c0fbee0eb00bb78;p=tahoe-lafs%2Ftahoe-lafs.git #509: remove non-streaming 'tahoe manifest' CLI form --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 58303505..7ad2e5ea 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -203,7 +203,6 @@ class ManifestOptions(VDriveOptions): ("verify-cap", None, "Only print verifycap, not pathname+cap"), ("repair-cap", None, "Only print repaircap, not pathname+cap"), ("raw", "r", "Display raw JSON data instead of parsed"), - ("stream", None, "Stream lines of JSON to stdout. With --storage-index or --verify-cap, stream those strings to stdout."), ] def parseArgs(self, where=''): self.where = where diff --git a/src/allmydata/scripts/tahoe_manifest.py b/src/allmydata/scripts/tahoe_manifest.py index be1c3295..0f20f9a9 100644 --- a/src/allmydata/scripts/tahoe_manifest.py +++ b/src/allmydata/scripts/tahoe_manifest.py @@ -1,17 +1,17 @@ import urllib, simplejson from twisted.protocols.basic import LineOnlyReceiver -from allmydata.util import base32 from allmydata.util.abbreviate import abbreviate_space_both -from allmydata import uri from allmydata.scripts.slow_operation import SlowOperationRunner from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path from allmydata.scripts.common_http import do_http class FakeTransport: disconnecting = False + class ManifestStreamer(LineOnlyReceiver): delimiter = "\n" + def __init__(self): self.transport = FakeTransport() @@ -71,35 +71,8 @@ class ManifestStreamer(LineOnlyReceiver): print >>stdout, d["cap"], "/".join([p.encode("utf-8") for p in d["path"]]) - - -class ManifestGrabber(SlowOperationRunner): - - def make_url(self, base, ophandle): - return base + "?t=start-manifest&ophandle=" + ophandle - - def write_results(self, data): - stdout = self.options.stdout - stderr = self.options.stderr - if self.options["storage-index"]: - for (path, cap) in data["manifest"]: - u = uri.from_string(str(cap)) - si = u.get_storage_index() - if si is not None: - print >>stdout, base32.b2a(si) - else: - for (path, cap) in data["manifest"]: - try: - print >>stdout, cap, "/".join(path) - except UnicodeEncodeError: - print >>stdout, cap, "/".join([p.encode("utf-8") - for p in path]) - def manifest(options): - if options["stream"]: - return ManifestStreamer().run(options) - else: - return ManifestGrabber().run(options) + return ManifestStreamer().run(options) class StatsGrabber(SlowOperationRunner): diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 1715b0a3..fbd281e1 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -2478,9 +2478,6 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): def do_test_cli_good(self, ignored): d = defer.succeed(None) - d.addCallback(lambda ign: self.do_cli_manifest1()) - d.addCallback(lambda ign: self.do_cli_manifest2()) - d.addCallback(lambda ign: self.do_cli_manifest3()) d.addCallback(lambda ign: self.do_cli_manifest_stream1()) d.addCallback(lambda ign: self.do_cli_manifest_stream2()) d.addCallback(lambda ign: self.do_cli_manifest_stream3()) @@ -2490,43 +2487,6 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): d.addCallback(lambda ign: self.do_cli_stats2()) return d - def do_cli_manifest1(self): - basedir = self.getdir("client0") - d = self._run_cli(["manifest", - "--node-directory", basedir, - self.root_uri]) - def _check((out,err)): - self.failUnlessEqual(err, "") - lines = [l for l in out.split("\n") if l] - self.failUnlessEqual(len(lines), 5) - caps = {} - for l in lines: - try: - cap, path = l.split(None, 1) - except ValueError: - cap = l.strip() - path = "" - caps[cap] = path - self.failUnless(self.root.get_uri() in caps) - self.failUnlessEqual(caps[self.root.get_uri()], "") - self.failUnlessEqual(caps[self.mutable.get_uri()], "mutable") - self.failUnlessEqual(caps[self.large.get_uri()], "large") - self.failUnlessEqual(caps[self.small.get_uri()], "small") - self.failUnlessEqual(caps[self.small2.get_uri()], "small2") - d.addCallback(_check) - return d - - def do_cli_manifest2(self): - basedir = self.getdir("client0") - d = self._run_cli(["manifest", - "--node-directory", basedir, - "--storage-index", self.root_uri]) - def _check((out,err)): - self.failUnlessEqual(err, "") - self._check_manifest_storage_index(out) - d.addCallback(_check) - return d - def _check_manifest_storage_index(self, out): lines = [l for l in out.split("\n") if l] self.failUnlessEqual(len(lines), 3) @@ -2534,35 +2494,10 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): self.failUnless(base32.b2a(self.mutable.get_storage_index()) in lines) self.failUnless(base32.b2a(self.large.get_storage_index()) in lines) - def do_cli_manifest3(self): - basedir = self.getdir("client0") - d = self._run_cli(["manifest", - "--node-directory", basedir, - "--raw", self.root_uri]) - def _check2r((out,err)): - self.failUnlessEqual(err, "") - data = simplejson.loads(out) - sis = data["storage-index"] - self.failUnlessEqual(len(sis), 3) - self.failUnless(base32.b2a(self.root.get_storage_index()) in sis) - self.failUnless(base32.b2a(self.mutable.get_storage_index()) in sis) - self.failUnless(base32.b2a(self.large.get_storage_index()) in sis) - self.failUnlessEqual(data["stats"]["count-files"], 4) - self.failUnlessEqual(data["origin"], - base32.b2a(self.root.get_storage_index())) - verifycaps = data["verifycaps"] - self.failUnlessEqual(len(verifycaps), 3) - self.failUnless(self.root.get_verify_cap().to_string() in verifycaps) - self.failUnless(self.mutable.get_verify_cap().to_string() in verifycaps) - self.failUnless(self.large.get_verify_cap().to_string() in verifycaps) - d.addCallback(_check2r) - return d - def do_cli_manifest_stream1(self): basedir = self.getdir("client0") d = self._run_cli(["manifest", "--node-directory", basedir, - "--stream", self.root_uri]) def _check((out,err)): self.failUnlessEqual(err, "") @@ -2589,7 +2524,7 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): basedir = self.getdir("client0") d = self._run_cli(["manifest", "--node-directory", basedir, - "--stream", "--raw", + "--raw", self.root_uri]) def _check((out,err)): self.failUnlessEqual(err, "") @@ -2602,7 +2537,7 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): basedir = self.getdir("client0") d = self._run_cli(["manifest", "--node-directory", basedir, - "--stream", "--storage-index", + "--storage-index", self.root_uri]) def _check((out,err)): self.failUnlessEqual(err, "") @@ -2614,7 +2549,7 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): basedir = self.getdir("client0") d = self._run_cli(["manifest", "--node-directory", basedir, - "--stream", "--verify-cap", + "--verify-cap", self.root_uri]) def _check((out,err)): self.failUnlessEqual(err, "") @@ -2630,7 +2565,7 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): basedir = self.getdir("client0") d = self._run_cli(["manifest", "--node-directory", basedir, - "--stream", "--repair-cap", + "--repair-cap", self.root_uri]) def _check((out,err)): self.failUnlessEqual(err, "")