mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-29 17:28:53 +00:00
Port to Python 3.
This commit is contained in:
parent
693e98e3a7
commit
f73f601f67
@ -1,19 +1,26 @@
|
||||
"""
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
from six import ensure_str, ensure_text
|
||||
|
||||
from urllib.parse import quote as url_quote
|
||||
import json
|
||||
|
||||
# Python 2 compatibility
|
||||
from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import str # noqa: F401
|
||||
|
||||
from twisted.protocols.basic import LineOnlyReceiver
|
||||
|
||||
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
|
||||
UnknownAliasError
|
||||
from allmydata.scripts.common_http import do_http, format_http_error
|
||||
from allmydata.util.encodingutil import quote_output, quote_path
|
||||
from allmydata.util.encodingutil import quote_output, quote_path, get_io_encoding
|
||||
|
||||
class Checker(object):
|
||||
pass
|
||||
@ -168,7 +175,9 @@ class DeepCheckOutput(LineOnlyReceiver, object):
|
||||
|
||||
# LIT files and directories do not have a "summary" field.
|
||||
summary = cr.get("summary", "Healthy (LIT)")
|
||||
print("%s: %s" % (quote_path(path), quote_output(summary, quotemarks=False)), file=stdout)
|
||||
# When Python 2 is dropped the ensure_text()/ensure_str() will be unnecessary.
|
||||
print(ensure_text(ensure_str("%s: %s") % (quote_path(path), quote_output(summary, quotemarks=False)),
|
||||
encoding=get_io_encoding()), file=stdout)
|
||||
|
||||
# always print out corrupt shares
|
||||
for shareloc in cr["results"].get("list-corrupt-shares", []):
|
||||
@ -245,11 +254,14 @@ class DeepCheckAndRepairOutput(LineOnlyReceiver, object):
|
||||
if not path:
|
||||
path = ["<root>"]
|
||||
# we don't seem to have a summary available, so build one
|
||||
# When Python 2 is dropped the ensure_text/ensure_str crap can be
|
||||
# dropped.
|
||||
if was_healthy:
|
||||
summary = "healthy"
|
||||
summary = ensure_str("healthy")
|
||||
else:
|
||||
summary = "not healthy"
|
||||
print("%s: %s" % (quote_path(path), summary), file=stdout)
|
||||
summary = ensure_str("not healthy")
|
||||
print(ensure_text(ensure_str("%s: %s") % (quote_path(path), summary),
|
||||
encoding=get_io_encoding()), file=stdout)
|
||||
|
||||
# always print out corrupt shares
|
||||
prr = crr.get("pre-repair-results", {})
|
||||
|
@ -16,6 +16,7 @@ from future.utils import PY2
|
||||
if PY2:
|
||||
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, open, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401
|
||||
|
||||
|
||||
PORTED_INTEGRATION_TESTS = [
|
||||
"integration.test_aaa_aardvark",
|
||||
"integration.test_servers_of_happiness",
|
||||
@ -103,6 +104,7 @@ PORTED_MODULES = [
|
||||
"allmydata.scripts.slow_operation",
|
||||
"allmydata.scripts.tahoe_add_alias",
|
||||
"allmydata.scripts.tahoe_backup",
|
||||
"allmydata.scripts.tahoe_check",
|
||||
"allmydata.scripts.types_",
|
||||
"allmydata.stats",
|
||||
"allmydata.storage_client",
|
||||
|
Loading…
Reference in New Issue
Block a user