From 02d96b970e3b0df5fd4629d8ec54ee5ac96818a5 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Wed, 28 Oct 2015 02:57:15 +0000 Subject: [PATCH 1/2] Quote local paths correctly in the output of node creation commands. fixes ticket:2556 Signed-off-by: Daira Hopwood --- src/allmydata/scripts/create_node.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/allmydata/scripts/create_node.py b/src/allmydata/scripts/create_node.py index 65cbb63ae..517085e59 100644 --- a/src/allmydata/scripts/create_node.py +++ b/src/allmydata/scripts/create_node.py @@ -3,7 +3,7 @@ import os, sys from allmydata.scripts.common import BasedirOptions, NoDefaultBasedirOptions from allmydata.scripts.default_nodedir import _default_nodedir from allmydata.util.assertutil import precondition -from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_output, quote_local_unicode_path +from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_local_unicode_path import allmydata class _CreateBaseOptions(BasedirOptions): @@ -109,7 +109,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr): if os.path.exists(basedir): if listdir_unicode(basedir): - print >>err, "The base directory %s is not empty." % quote_output(basedir) + print >>err, "The base directory %s is not empty." % quote_local_unicode_path(basedir) print >>err, "To avoid clobbering anything, I am going to quit now." print >>err, "Please use a different directory, or empty this one." return -1 @@ -165,7 +165,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr): from allmydata.util import fileutil fileutil.make_dirs(os.path.join(basedir, "private"), 0700) - print >>out, "Node created in %s" % quote_output(basedir) + print >>out, "Node created in %s" % quote_local_unicode_path(basedir) if not config.get("introducer", ""): print >>out, " Please set [client]introducer.furl= in tahoe.cfg!" print >>out, " The node cannot connect to a grid without it." @@ -185,7 +185,7 @@ def create_introducer(config, out=sys.stdout, err=sys.stderr): if os.path.exists(basedir): if listdir_unicode(basedir): - print >>err, "The base directory %s is not empty." % quote_output(basedir) + print >>err, "The base directory %s is not empty." % quote_local_unicode_path(basedir) print >>err, "To avoid clobbering anything, I am going to quit now." print >>err, "Please use a different directory, or empty this one." return -1 @@ -200,7 +200,7 @@ def create_introducer(config, out=sys.stdout, err=sys.stderr): write_node_config(c, config) c.close() - print >>out, "Introducer created in %s" % quote_output(basedir) + print >>out, "Introducer created in %s" % quote_local_unicode_path(basedir) return 0 From 8ce7e2430c4b956481715e8300218b5963ef8e30 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Tue, 1 Dec 2015 17:58:16 +0000 Subject: [PATCH 2/2] Add test for 'tahoe create-node/client/introducer' output. closes ticket:2556 Signed-off-by: Daira Hopwood --- src/allmydata/test/test_runner.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py index 3c79777f8..66ca466c5 100644 --- a/src/allmydata/test/test_runner.py +++ b/src/allmydata/test/test_runner.py @@ -298,6 +298,19 @@ class CreateNode(unittest.TestCase): self.failUnless(os.path.exists(n3)) self.failUnless(os.path.exists(os.path.join(n3, tac))) + if kind in ("client", "node", "introducer"): + # test that the output (without --quiet) includes the base directory + n4 = os.path.join(basedir, command + "-n4") + argv = [command, n4] + rc, out, err = self.run_tahoe(argv) + self.failUnlessEqual(err, "") + self.failUnlessIn(" created in ", out) + self.failUnlessIn(n4, out) + self.failIfIn("\\\\?\\", out) + self.failUnlessEqual(rc, 0) + self.failUnless(os.path.exists(n4)) + self.failUnless(os.path.exists(os.path.join(n4, tac))) + # make sure it rejects too many arguments argv = [command, "basedir", "extraarg"] self.failUnlessRaises(usage.UsageError,