mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-03 11:44:11 +00:00
More progress on Python 3, unbreak Python 2.
This commit is contained in:
parent
fb621f4388
commit
36bf9224e6
@ -904,10 +904,6 @@ class _Client(node.Node, pollmixin.PollMixin):
|
|||||||
if helper_furl in ("None", ""):
|
if helper_furl in ("None", ""):
|
||||||
helper_furl = None
|
helper_furl = None
|
||||||
|
|
||||||
# FURLs need to be bytes:
|
|
||||||
if helper_furl is not None:
|
|
||||||
helper_furl = helper_furl.encode("utf-8")
|
|
||||||
|
|
||||||
DEP = self.encoding_params
|
DEP = self.encoding_params
|
||||||
DEP["k"] = int(self.config.get_config("client", "shares.needed", DEP["k"]))
|
DEP["k"] = int(self.config.get_config("client", "shares.needed", DEP["k"]))
|
||||||
DEP["n"] = int(self.config.get_config("client", "shares.total", DEP["n"]))
|
DEP["n"] = int(self.config.get_config("client", "shares.total", DEP["n"]))
|
||||||
|
@ -1825,7 +1825,7 @@ class Uploader(service.MultiService, log.PrefixingLogMixin):
|
|||||||
def startService(self):
|
def startService(self):
|
||||||
service.MultiService.startService(self)
|
service.MultiService.startService(self)
|
||||||
if self._helper_furl:
|
if self._helper_furl:
|
||||||
self.parent.tub.connectTo(self._helper_furl,
|
self.parent.tub.connectTo(self._helper_furl.encode("utf-8"),
|
||||||
self._got_helper)
|
self._got_helper)
|
||||||
|
|
||||||
def _got_helper(self, helper):
|
def _got_helper(self, helper):
|
||||||
|
@ -47,12 +47,17 @@ class VerboseError(Error):
|
|||||||
|
|
||||||
@inlineCallbacks
|
@inlineCallbacks
|
||||||
def do_http(method, url, **kwargs):
|
def do_http(method, url, **kwargs):
|
||||||
|
"""
|
||||||
|
Run HTTP query, return Deferred of body as Unicode.
|
||||||
|
"""
|
||||||
response = yield treq.request(method, url, persistent=False, **kwargs)
|
response = yield treq.request(method, url, persistent=False, **kwargs)
|
||||||
body = yield treq.content(response)
|
body = yield treq.text_content(response, "utf-8")
|
||||||
# TODO: replace this with response.fail_for_status when
|
# TODO: replace this with response.fail_for_status when
|
||||||
# https://github.com/twisted/treq/pull/159 has landed
|
# https://github.com/twisted/treq/pull/159 has landed
|
||||||
if 400 <= response.code < 600:
|
if 400 <= response.code < 600:
|
||||||
raise VerboseError(response.code, response=body)
|
raise VerboseError(
|
||||||
|
response.code, response="For request {} to {}, got: {}".format(
|
||||||
|
method, url, body))
|
||||||
returnValue(body)
|
returnValue(body)
|
||||||
|
|
||||||
|
|
||||||
|
@ -632,7 +632,7 @@ def _render_config(config):
|
|||||||
"""
|
"""
|
||||||
Convert a ``dict`` of ``dict`` of ``bytes`` to an ini-format string.
|
Convert a ``dict`` of ``dict`` of ``bytes`` to an ini-format string.
|
||||||
"""
|
"""
|
||||||
return "\n\n".join(list(
|
return u"\n\n".join(list(
|
||||||
_render_config_section(k, v)
|
_render_config_section(k, v)
|
||||||
for (k, v)
|
for (k, v)
|
||||||
in config.items()
|
in config.items()
|
||||||
@ -643,7 +643,7 @@ def _render_config_section(heading, values):
|
|||||||
Convert a ``bytes`` heading and a ``dict`` of ``bytes`` to an ini-format
|
Convert a ``bytes`` heading and a ``dict`` of ``bytes`` to an ini-format
|
||||||
section as ``bytes``.
|
section as ``bytes``.
|
||||||
"""
|
"""
|
||||||
return "[{}]\n{}\n".format(
|
return u"[{}]\n{}\n".format(
|
||||||
heading, _render_section_values(values)
|
heading, _render_section_values(values)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -652,8 +652,8 @@ def _render_section_values(values):
|
|||||||
Convert a ``dict`` of ``bytes`` to the body of an ini-format section as
|
Convert a ``dict`` of ``bytes`` to the body of an ini-format section as
|
||||||
``bytes``.
|
``bytes``.
|
||||||
"""
|
"""
|
||||||
return "\n".join(list(
|
return u"\n".join(list(
|
||||||
"{} = {}".format(k, v)
|
u"{} = {}".format(k, v)
|
||||||
for (k, v)
|
for (k, v)
|
||||||
in sorted(values.items())
|
in sorted(values.items())
|
||||||
))
|
))
|
||||||
@ -1856,7 +1856,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
|||||||
"largest-directory-children": 3,
|
"largest-directory-children": 3,
|
||||||
"largest-immutable-file": 112,
|
"largest-immutable-file": 112,
|
||||||
}
|
}
|
||||||
for k,v in expected.iteritems():
|
for k,v in expected.items():
|
||||||
self.failUnlessEqual(stats[k], v,
|
self.failUnlessEqual(stats[k], v,
|
||||||
"stats[%s] was %s, not %s" %
|
"stats[%s] was %s, not %s" %
|
||||||
(k, stats[k], v))
|
(k, stats[k], v))
|
||||||
@ -1939,7 +1939,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
|||||||
return do_http("post", url, data=body, headers=headers)
|
return do_http("post", url, data=body, headers=headers)
|
||||||
|
|
||||||
def _test_web(self, res):
|
def _test_web(self, res):
|
||||||
public = "uri/" + self._root_directory_uri
|
public = "uri/" + unicode(self._root_directory_uri, "ascii")
|
||||||
d = self.GET("")
|
d = self.GET("")
|
||||||
def _got_welcome(page):
|
def _got_welcome(page):
|
||||||
html = page.replace('\n', ' ')
|
html = page.replace('\n', ' ')
|
||||||
@ -1948,7 +1948,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase):
|
|||||||
"I didn't see the right '%s' message in:\n%s" % (connected_re, page))
|
"I didn't see the right '%s' message in:\n%s" % (connected_re, page))
|
||||||
# nodeids/tubids don't have any regexp-special characters
|
# nodeids/tubids don't have any regexp-special characters
|
||||||
nodeid_re = r'<th>Node ID:</th>\s*<td title="TubID: %s">%s</td>' % (
|
nodeid_re = r'<th>Node ID:</th>\s*<td title="TubID: %s">%s</td>' % (
|
||||||
self.clients[0].get_long_tubid(), self.clients[0].get_long_nodeid())
|
self.clients[0].get_long_tubid(), unicode(self.clients[0].get_long_nodeid(), "ascii"))
|
||||||
self.failUnless(re.search(nodeid_re, html),
|
self.failUnless(re.search(nodeid_re, html),
|
||||||
"I didn't see the right '%s' message in:\n%s" % (nodeid_re, page))
|
"I didn't see the right '%s' message in:\n%s" % (nodeid_re, page))
|
||||||
self.failUnless("Helper: 0 active uploads" in page)
|
self.failUnless("Helper: 0 active uploads" in page)
|
||||||
|
Loading…
Reference in New Issue
Block a user