import os.path
import urllib
import simplejson
+import sys
from cStringIO import StringIO
from twisted.python.failure import Failure
from allmydata.scripts.common import get_alias, escape_path, \
DefaultAliasMarker, UnknownAliasError
from allmydata.scripts.common_http import do_http
from allmydata import uri
+from twisted.python import usage
+from allmydata.util.stringutils import unicode_to_url, listdir_unicode, open_unicode
+from allmydata.util.assertutil import precondition
+
def ascii_or_none(s):
if s is None:
class LocalFileSource:
def __init__(self, pathname):
+ precondition(isinstance(pathname, unicode), pathname)
self.pathname = pathname
def need_to_copy_bytes(self):
class LocalFileTarget:
def __init__(self, pathname):
+ precondition(isinstance(pathname, unicode), pathname)
self.pathname = pathname
def put_file(self, inf):
outf = open(self.pathname, "wb")
class LocalMissingTarget:
def __init__(self, pathname):
+ precondition(isinstance(pathname, unicode), pathname)
self.pathname = pathname
def put_file(self, inf):
class LocalDirectorySource:
def __init__(self, progressfunc, pathname):
+ precondition(isinstance(pathname, unicode), pathname)
+
self.progressfunc = progressfunc
self.pathname = pathname
self.children = None
if self.children is not None:
return
self.children = {}
- children = os.listdir(self.pathname)
+ children = listdir_unicode(self.pathname)
for i,n in enumerate(children):
self.progressfunc("examining %d of %d" % (i, len(children)))
pn = os.path.join(self.pathname, n)
class LocalDirectoryTarget:
def __init__(self, progressfunc, pathname):
+ precondition(isinstance(pathname, unicode), pathname)
+
self.progressfunc = progressfunc
self.pathname = pathname
self.children = None
if self.children is not None:
return
self.children = {}
- children = os.listdir(self.pathname)
+ children = listdir_unicode(self.pathname)
for i,n in enumerate(children):
self.progressfunc("examining %d of %d" % (i, len(children)))
pn = os.path.join(self.pathname, n)
return LocalDirectoryTarget(self.progressfunc, pathname)
def put_file(self, name, inf):
+ precondition(isinstance(name, unicode), name)
pathname = os.path.join(self.pathname, name)
- outf = open(pathname, "wb")
+ outf = open_unicode(pathname, "wb")
while True:
data = inf.read(32768)
if not data:
if self.writecap:
url = self.nodeurl + "/".join(["uri",
urllib.quote(self.writecap),
- urllib.quote(name.encode('utf-8'))])
+ urllib.quote(unicode_to_url(name))])
self.children[name] = TahoeFileTarget(self.nodeurl, mutable,
writecap, readcap, url)
elif data[0] == "dirnode":