mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-02 11:16:41 +00:00
Merge pull request #203 from tahoe-lafs/2556.quote-paths-in-node-creation.0
2556.quote-paths-in-node-creation.0
This commit is contained in:
commit
42c159bf35
@ -3,7 +3,7 @@ import os, sys
|
|||||||
from allmydata.scripts.common import BasedirOptions, NoDefaultBasedirOptions
|
from allmydata.scripts.common import BasedirOptions, NoDefaultBasedirOptions
|
||||||
from allmydata.scripts.default_nodedir import _default_nodedir
|
from allmydata.scripts.default_nodedir import _default_nodedir
|
||||||
from allmydata.util.assertutil import precondition
|
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
|
import allmydata
|
||||||
|
|
||||||
class _CreateBaseOptions(BasedirOptions):
|
class _CreateBaseOptions(BasedirOptions):
|
||||||
@ -109,7 +109,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
|
|||||||
|
|
||||||
if os.path.exists(basedir):
|
if os.path.exists(basedir):
|
||||||
if listdir_unicode(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, "To avoid clobbering anything, I am going to quit now."
|
||||||
print >>err, "Please use a different directory, or empty this one."
|
print >>err, "Please use a different directory, or empty this one."
|
||||||
return -1
|
return -1
|
||||||
@ -165,7 +165,7 @@ def create_node(config, out=sys.stdout, err=sys.stderr):
|
|||||||
|
|
||||||
from allmydata.util import fileutil
|
from allmydata.util import fileutil
|
||||||
fileutil.make_dirs(os.path.join(basedir, "private"), 0700)
|
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", ""):
|
if not config.get("introducer", ""):
|
||||||
print >>out, " Please set [client]introducer.furl= in tahoe.cfg!"
|
print >>out, " Please set [client]introducer.furl= in tahoe.cfg!"
|
||||||
print >>out, " The node cannot connect to a grid without it."
|
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 os.path.exists(basedir):
|
||||||
if listdir_unicode(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, "To avoid clobbering anything, I am going to quit now."
|
||||||
print >>err, "Please use a different directory, or empty this one."
|
print >>err, "Please use a different directory, or empty this one."
|
||||||
return -1
|
return -1
|
||||||
@ -200,7 +200,7 @@ def create_introducer(config, out=sys.stdout, err=sys.stderr):
|
|||||||
write_node_config(c, config)
|
write_node_config(c, config)
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
print >>out, "Introducer created in %s" % quote_output(basedir)
|
print >>out, "Introducer created in %s" % quote_local_unicode_path(basedir)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
@ -298,6 +298,19 @@ class CreateNode(unittest.TestCase):
|
|||||||
self.failUnless(os.path.exists(n3))
|
self.failUnless(os.path.exists(n3))
|
||||||
self.failUnless(os.path.exists(os.path.join(n3, tac)))
|
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
|
# make sure it rejects too many arguments
|
||||||
argv = [command, "basedir", "extraarg"]
|
argv = [command, "basedir", "extraarg"]
|
||||||
self.failUnlessRaises(usage.UsageError,
|
self.failUnlessRaises(usage.UsageError,
|
||||||
|
Loading…
Reference in New Issue
Block a user