]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Additional Unicode basedir changes for ticket798 branch.
authordavid-sarah <david-sarah@jacaranda.org>
Mon, 2 Aug 2010 01:05:52 +0000 (18:05 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Mon, 2 Aug 2010 01:05:52 +0000 (18:05 -0700)
src/allmydata/scripts/cli.py
src/allmydata/scripts/common.py
src/allmydata/scripts/create_node.py
src/allmydata/scripts/keygen.py

index 4150b877637bb5915e635db94f8bdeb9883e4442..8dff5de2d409ab61db01432eca2cb6efbeb5b3de 100644 (file)
@@ -1,7 +1,7 @@
 import os.path, re, sys, fnmatch
 from twisted.python import usage
 from allmydata.scripts.common import BaseOptions, get_aliases
-from allmydata.util.encodingutil import argv_to_unicode, argv_to_abspath, quote_output
+from allmydata.util.encodingutil import argv_to_unicode, argv_to_abspath
 
 NODEURL_RE=re.compile("http(s?)://([^:]*)(:([1-9][0-9]*))?")
 
index a76d0a34e82954a598671d80693d53be5e4b711c..f4d81108b75d82cbd6b1742518f3b945757ea3aa 100644 (file)
@@ -39,30 +39,27 @@ class BasedirMixin:
             raise usage.UsageError("<basedir> parameter is required")
         if self['basedir']:
             del self['basedir']
-        self['basedirs'] = [os.path.abspath(os.path.expanduser(b)) for b in self.basedirs]
+        self['basedirs'] = self.basedirs
 
     def parseArgs(self, *args):
         self.basedirs = []
         if self['basedir']:
-            precondition(isinstance(self['basedir'], (str, unicode)), self['basedir'])
-            self.basedirs.append(self['basedir'])
+            precondition(isinstance(self['basedir'], str), self['basedir'])
+            self.basedirs.append(argv_to_abspath(self['basedir']))
         if self['multiple']:
-            precondition(not [x for x in args if not isinstance(x, (str, unicode))], args)
-            self.basedirs.extend(args)
+            self.basedirs.extend(map(argv_to_abspath, args))
         else:
             if len(args) == 0 and not self.basedirs:
                 if sys.platform == 'win32':
                     from allmydata.windows import registry
                     rbdp = registry.get_base_dir_path()
                     if rbdp:
-                        precondition(isinstance(registry.get_base_dir_path(), (str, unicode)), registry.get_base_dir_path())
+                        precondition(isinstance(registry.get_base_dir_path(), unicode), registry.get_base_dir_path())
                         self.basedirs.append(rbdp)
                 else:
-                    precondition(isinstance(os.path.expanduser("~/.tahoe"), (str, unicode)), os.path.expanduser("~/.tahoe"))
-                    self.basedirs.append(os.path.expanduser("~/.tahoe"))
+                    self.basedirs.append(abspath_expanduser_unicode(u"~/.tahoe"))
             if len(args) > 0:
-                precondition(isinstance(args[0], (str, unicode)), args[0])
-                self.basedirs.append(args[0])
+                self.basedirs.append(argv_to_abspath(args[0]))
             if len(args) > 1:
                 raise usage.UsageError("I wasn't expecting so many arguments")
 
@@ -71,15 +68,12 @@ class NoDefaultBasedirMixin(BasedirMixin):
         # create-client won't default to --basedir=~/.tahoe
         self.basedirs = []
         if self['basedir']:
-            precondition(isinstance(self['basedir'], (str, unicode)), self['basedir'])
-            self.basedirs.append(self['basedir'])
+            self.basedirs.append(argv_to_abspath(self['basedir']))
         if self['multiple']:
-            precondition(not [x for x in args if not isinstance(x, (str, unicode))], args)
-            self.basedirs.extend(args)
+            self.basedirs.extend(map(argv_to_abspath, args))
         else:
             if len(args) > 0:
-                precondition(isinstance(args[0], (str, unicode)), args[0])
-                self.basedirs.append(args[0])
+                self.basedirs.append(argv_to_abspath(args[0]))
             if len(args) > 1:
                 raise usage.UsageError("I wasn't expecting so many arguments")
         if not self.basedirs:
index 65228bf893081583f342ae63428e96e1d748bdfc..d98b421d5682807fa6ec277469bfabb348788a39 100644 (file)
@@ -2,6 +2,8 @@
 import os, sys
 from twisted.python import usage
 from allmydata.scripts.common import BasedirMixin, NoDefaultBasedirMixin
+from allmydata.util.assertutil import precondition
+from allmydata.util.encodingutil import listdir_unicode, argv_to_unicode, quote_output
 import allmydata
 
 class CreateClientOptions(BasedirMixin, usage.Options):
index 1b0cbad80aa2f8dfa3aeb64d6f81fdcf2815f410..cd8ff364343f0e0afd4db4bfcfec902044a8cfa6 100644 (file)
@@ -2,6 +2,7 @@
 import os, sys
 from twisted.python import usage
 #from allmydata.scripts.common import BasedirMixin, NoDefaultBasedirMixin
+from allmydata.util.encodingutil import listdir_unicode, argv_to_abspath, quote_output
 
 class CreateKeyGeneratorOptions(usage.Options):
     optParameters = [
@@ -24,10 +25,10 @@ k.setServiceParent(application)
 """
 
 def create_key_generator(config, out=sys.stdout, err=sys.stderr):
-    basedir = config['basedir']
-    if not basedir:
+    if not config['basedir']:
         print >>err, "a basedir was not provided, please use --basedir or -C"
         return -1
+    basedir = argv_to_abspath(config['basedir'])
     if os.path.exists(basedir):
         if listdir_unicode(basedir):
             print >>err, "The base directory %s is not empty." % quote_output(basedir)