From c98d90bf74675694cfa56bbcf55710a91b399c20 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 09:41:49 -0400 Subject: [PATCH 1/9] News file. --- newsfragments/3716.minor | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 newsfragments/3716.minor diff --git a/newsfragments/3716.minor b/newsfragments/3716.minor new file mode 100644 index 000000000..e69de29bb From 250ca3170db995c0f8579b239c4692070e0a7d14 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 09:42:13 -0400 Subject: [PATCH 2/9] Port to Python 3. --- src/allmydata/scripts/admin.py | 19 ++++++++++++++----- src/allmydata/util/_python3.py | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/allmydata/scripts/admin.py b/src/allmydata/scripts/admin.py index abe3d093c..a9feed0dd 100644 --- a/src/allmydata/scripts/admin.py +++ b/src/allmydata/scripts/admin.py @@ -1,6 +1,15 @@ +""" +Ported to Python 3. +""" +from __future__ import unicode_literals +from __future__ import absolute_import +from __future__ import division from __future__ import print_function -from past.builtins import unicode +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_binary try: @@ -25,9 +34,9 @@ def print_keypair(options): from allmydata.crypto import ed25519 out = options.stdout private_key, public_key = ed25519.create_signing_keypair() - print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"), + print("private:", str(ed25519.string_from_signing_key(private_key), "ascii"), file=out) - print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"), + print("public:", str(ed25519.string_from_verifying_key(public_key), "ascii"), file=out) class DerivePubkeyOptions(BaseOptions): @@ -52,8 +61,8 @@ def derive_pubkey(options): privkey_vs = options.privkey privkey_vs = ensure_binary(privkey_vs) private_key, public_key = ed25519.signing_keypair_from_string(privkey_vs) - print("private:", unicode(ed25519.string_from_signing_key(private_key), "ascii"), file=out) - print("public:", unicode(ed25519.string_from_verifying_key(public_key), "ascii"), file=out) + print("private:", str(ed25519.string_from_signing_key(private_key), "ascii"), file=out) + print("public:", str(ed25519.string_from_verifying_key(public_key), "ascii"), file=out) return 0 class AdminCommand(BaseOptions): diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 4bbfc0e68..dbdd8b92b 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -88,6 +88,7 @@ PORTED_MODULES = [ "allmydata.node", "allmydata.nodemaker", "allmydata.scripts", + "allmydata.scripts.admin", "allmydata.scripts.create_node", "allmydata.scripts.runner", "allmydata.scripts.types_", From 66f53fada8a8e5d0d5de4140358cb517a2370a6c Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 09:46:15 -0400 Subject: [PATCH 3/9] Port to Python 3. --- src/allmydata/scripts/backupdb.py | 10 ++++++++++ src/allmydata/util/_python3.py | 1 + 2 files changed, 11 insertions(+) diff --git a/src/allmydata/scripts/backupdb.py b/src/allmydata/scripts/backupdb.py index 1bffbbfc3..c7827e56e 100644 --- a/src/allmydata/scripts/backupdb.py +++ b/src/allmydata/scripts/backupdb.py @@ -1,5 +1,15 @@ +""" +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 + import os.path, sys, time, random, stat from allmydata.util.netstring import netstring diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index dbdd8b92b..510e50d35 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -89,6 +89,7 @@ PORTED_MODULES = [ "allmydata.nodemaker", "allmydata.scripts", "allmydata.scripts.admin", + "allmydata.scripts.backupdb", "allmydata.scripts.create_node", "allmydata.scripts.runner", "allmydata.scripts.types_", From a2280b7660baaa7623faf2c91151819bbebe285a Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 09:57:09 -0400 Subject: [PATCH 4/9] Port to Python 3. --- src/allmydata/scripts/cli.py | 18 ++++++++++++++---- src/allmydata/test/cli/test_backup.py | 10 ++++++---- src/allmydata/util/_python3.py | 3 ++- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 011dc3b21..41695aa47 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -1,6 +1,15 @@ +""" +Ported to Python 3. +""" +from __future__ import unicode_literals +from __future__ import absolute_import +from __future__ import division from __future__ import print_function -from past.builtins import unicode +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 + import os.path, re, fnmatch @@ -38,7 +47,7 @@ class FileStoreOptions(BaseOptions): # compute a node-url from the existing options, put in self['node-url'] if self['node-url']: - if (not isinstance(self['node-url'], (bytes, unicode)) + if (not isinstance(self['node-url'], (bytes, str)) or not NODEURL_RE.match(self['node-url'])): msg = ("--node-url is required to be a string and look like " "\"http://HOSTNAMEORADDR:PORT\", not: %r" % @@ -354,8 +363,9 @@ class BackupOptions(FileStoreOptions): abs_filepath = argv_to_abspath(filepath) try: exclude_file = open(abs_filepath) - except: - raise BackupConfigurationError('Error opening exclude file %s.' % quote_local_unicode_path(abs_filepath)) + except Exception as e: + raise BackupConfigurationError('Error opening exclude file %s. (Error: %s)' % ( + quote_local_unicode_path(abs_filepath), e)) try: for line in exclude_file: self.opt_exclude(line) diff --git a/src/allmydata/test/cli/test_backup.py b/src/allmydata/test/cli/test_backup.py index 4bd4b8bfa..4cc7e865f 100644 --- a/src/allmydata/test/cli/test_backup.py +++ b/src/allmydata/test/cli/test_backup.py @@ -9,9 +9,7 @@ from __future__ import unicode_literals 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 - import __builtin__ as builtins -else: - import builtins + import os.path from six.moves import cStringIO as StringIO @@ -430,7 +428,11 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase): else: return original_open(name, *args) - patcher = MonkeyPatcher((builtins, 'open', call_file)) + if PY2: + from allmydata.scripts import cli as module_to_patch + else: + import builtins as module_to_patch + patcher = MonkeyPatcher((module_to_patch, 'open', call_file)) patcher.runWithPatches(parse_options, basedir, "backup", ['--exclude-from', unicode_to_argv(exclude_file), 'from', 'to']) self.failUnless(ns.called) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 510e50d35..7767a52d8 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -89,7 +89,8 @@ PORTED_MODULES = [ "allmydata.nodemaker", "allmydata.scripts", "allmydata.scripts.admin", - "allmydata.scripts.backupdb", + "allmydata.scripts.backupdb" + "allmydata.scripts.cli", "allmydata.scripts.create_node", "allmydata.scripts.runner", "allmydata.scripts.types_", From bcf2374dfe0ff83f9014c84519436f31c6b6922d Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 10:27:07 -0400 Subject: [PATCH 5/9] Port to Python 3. --- src/allmydata/scripts/common_http.py | 10 ++++++++++ src/allmydata/util/_python3.py | 1 + 2 files changed, 11 insertions(+) diff --git a/src/allmydata/scripts/common_http.py b/src/allmydata/scripts/common_http.py index a53f6baa8..bf47f2dd6 100644 --- a/src/allmydata/scripts/common_http.py +++ b/src/allmydata/scripts/common_http.py @@ -1,5 +1,15 @@ +""" +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 + import os from io import BytesIO from six.moves import urllib, http_client diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 7767a52d8..67a93198b 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -91,6 +91,7 @@ PORTED_MODULES = [ "allmydata.scripts.admin", "allmydata.scripts.backupdb" "allmydata.scripts.cli", + "allmydata.scripts.common_http", "allmydata.scripts.create_node", "allmydata.scripts.runner", "allmydata.scripts.types_", From e3f079555086e0180df1d9eb8750d7c42658766a Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 10:31:26 -0400 Subject: [PATCH 6/9] Port to Python 3. --- src/allmydata/scripts/common.py | 12 ++++++++++++ src/allmydata/util/_python3.py | 1 + 2 files changed, 13 insertions(+) diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index bc969de93..e2f13b262 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -1,7 +1,19 @@ # coding: utf-8 +""" +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 + + import os, sys, textwrap import codecs from os.path import join diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 67a93198b..eee8bf65b 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -92,6 +92,7 @@ PORTED_MODULES = [ "allmydata.scripts.backupdb" "allmydata.scripts.cli", "allmydata.scripts.common_http", + "allmydata.scripts.common", "allmydata.scripts.create_node", "allmydata.scripts.runner", "allmydata.scripts.types_", From 7c170317c00a33764b5967e6607384f6fde9afd1 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 10:41:53 -0400 Subject: [PATCH 7/9] Remove some cruft. --- src/allmydata/scripts/common.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/allmydata/scripts/common.py b/src/allmydata/scripts/common.py index e2f13b262..0a9ab8714 100644 --- a/src/allmydata/scripts/common.py +++ b/src/allmydata/scripts/common.py @@ -12,6 +12,8 @@ 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 +else: + from typing import Union import os, sys, textwrap @@ -29,13 +31,6 @@ from yaml import ( safe_dump, ) -# Python 2 compatibility -from future.utils import PY2 -if PY2: - from future.builtins import str # noqa: F401 -else: - from typing import Union - from twisted.python import usage from allmydata.util.assertutil import precondition From 0655b020505529f0182e808d992fd10224f35b52 Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Fri, 14 May 2021 10:50:04 -0400 Subject: [PATCH 8/9] Port to Python 3. --- src/allmydata/scripts/debug.py | 104 ++++++++++++++++++--------------- src/allmydata/util/_python3.py | 1 + 2 files changed, 57 insertions(+), 48 deletions(-) diff --git a/src/allmydata/scripts/debug.py b/src/allmydata/scripts/debug.py index ba40519de..2d6ba4602 100644 --- a/src/allmydata/scripts/debug.py +++ b/src/allmydata/scripts/debug.py @@ -1,12 +1,20 @@ +""" +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, bchr +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 + try: from allmydata.scripts.types_ import SubCommands except ImportError: pass -from future.utils import bchr -from past.builtins import unicode # do not import any allmydata modules at this level. Do that from inside # individual functions instead. @@ -94,7 +102,7 @@ def dump_immutable_chk_share(f, out, options): def to_string(v): if isinstance(v, bytes): - return unicode(v, "utf-8") + return str(v, "utf-8") else: return str(v) @@ -173,9 +181,9 @@ def format_expiration_time(expiration_time): remains = expiration_time - now when = "%ds" % remains if remains > 24*3600: - when += " (%d days)" % (remains / (24*3600)) + when += " (%d days)" % (remains // (24*3600)) elif remains > 3600: - when += " (%d hours)" % (remains / 3600) + when += " (%d hours)" % (remains // 3600) return when @@ -205,7 +213,7 @@ def dump_mutable_share(options): print(file=out) print("Mutable slot found:", file=out) print(" share_type: %s" % share_type, file=out) - print(" write_enabler: %s" % unicode(base32.b2a(WE), "utf-8"), file=out) + print(" write_enabler: %s" % str(base32.b2a(WE), "utf-8"), file=out) print(" WE for nodeid: %s" % idlib.nodeid_b2a(nodeid), file=out) print(" num_extra_leases: %d" % num_extra_leases, file=out) print(" container_size: %d" % container_size, file=out) @@ -217,8 +225,8 @@ def dump_mutable_share(options): print(" ownerid: %d" % lease.owner_num, file=out) when = format_expiration_time(lease.expiration_time) print(" expires in %s" % when, file=out) - print(" renew_secret: %s" % unicode(base32.b2a(lease.renew_secret), "utf-8"), file=out) - print(" cancel_secret: %s" % unicode(base32.b2a(lease.cancel_secret), "utf-8"), file=out) + print(" renew_secret: %s" % str(base32.b2a(lease.renew_secret), "utf-8"), file=out) + print(" cancel_secret: %s" % str(base32.b2a(lease.cancel_secret), "utf-8"), file=out) print(" secrets are for nodeid: %s" % idlib.nodeid_b2a(lease.nodeid), file=out) else: print("No leases.", file=out) @@ -266,8 +274,8 @@ def dump_SDMF_share(m, length, options): print(" SDMF contents:", file=out) print(" seqnum: %d" % seqnum, file=out) - print(" root_hash: %s" % unicode(base32.b2a(root_hash), "utf-8"), file=out) - print(" IV: %s" % unicode(base32.b2a(IV), "utf-8"), file=out) + print(" root_hash: %s" % str(base32.b2a(root_hash), "utf-8"), file=out) + print(" IV: %s" % str(base32.b2a(IV), "utf-8"), file=out) print(" required_shares: %d" % k, file=out) print(" total_shares: %d" % N, file=out) print(" segsize: %d" % segsize, file=out) @@ -360,7 +368,7 @@ def dump_MDMF_share(m, length, options): print(" MDMF contents:", file=out) print(" seqnum: %d" % seqnum, file=out) - print(" root_hash: %s" % unicode(base32.b2a(root_hash), "utf-8"), file=out) + print(" root_hash: %s" % str(base32.b2a(root_hash), "utf-8"), file=out) #print(" IV: %s" % base32.b2a(IV), file=out) print(" required_shares: %d" % k, file=out) print(" total_shares: %d" % N, file=out) @@ -485,19 +493,19 @@ def _dump_secrets(storage_index, secret, nodeid, out): if secret: crs = hashutil.my_renewal_secret_hash(secret) - print(" client renewal secret:", unicode(base32.b2a(crs), "ascii"), file=out) + print(" client renewal secret:", str(base32.b2a(crs), "ascii"), file=out) frs = hashutil.file_renewal_secret_hash(crs, storage_index) - print(" file renewal secret:", unicode(base32.b2a(frs), "ascii"), file=out) + print(" file renewal secret:", str(base32.b2a(frs), "ascii"), file=out) if nodeid: renew = hashutil.bucket_renewal_secret_hash(frs, nodeid) - print(" lease renewal secret:", unicode(base32.b2a(renew), "ascii"), file=out) + print(" lease renewal secret:", str(base32.b2a(renew), "ascii"), file=out) ccs = hashutil.my_cancel_secret_hash(secret) - print(" client cancel secret:", unicode(base32.b2a(ccs), "ascii"), file=out) + print(" client cancel secret:", str(base32.b2a(ccs), "ascii"), file=out) fcs = hashutil.file_cancel_secret_hash(ccs, storage_index) - print(" file cancel secret:", unicode(base32.b2a(fcs), "ascii"), file=out) + print(" file cancel secret:", str(base32.b2a(fcs), "ascii"), file=out) if nodeid: cancel = hashutil.bucket_cancel_secret_hash(fcs, nodeid) - print(" lease cancel secret:", unicode(base32.b2a(cancel), "ascii"), file=out) + print(" lease cancel secret:", str(base32.b2a(cancel), "ascii"), file=out) def dump_uri_instance(u, nodeid, secret, out, show_header=True): from allmydata import uri @@ -508,19 +516,19 @@ def dump_uri_instance(u, nodeid, secret, out, show_header=True): if isinstance(u, uri.CHKFileURI): if show_header: print("CHK File:", file=out) - print(" key:", unicode(base32.b2a(u.key), "ascii"), file=out) - print(" UEB hash:", unicode(base32.b2a(u.uri_extension_hash), "ascii"), file=out) + print(" key:", str(base32.b2a(u.key), "ascii"), file=out) + print(" UEB hash:", str(base32.b2a(u.uri_extension_hash), "ascii"), file=out) print(" size:", u.size, file=out) print(" k/N: %d/%d" % (u.needed_shares, u.total_shares), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) _dump_secrets(u.get_storage_index(), secret, nodeid, out) elif isinstance(u, uri.CHKFileVerifierURI): if show_header: print("CHK Verifier URI:", file=out) - print(" UEB hash:", unicode(base32.b2a(u.uri_extension_hash), "ascii"), file=out) + print(" UEB hash:", str(base32.b2a(u.uri_extension_hash), "ascii"), file=out) print(" size:", u.size, file=out) print(" k/N: %d/%d" % (u.needed_shares, u.total_shares), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) elif isinstance(u, uri.LiteralFileURI): if show_header: @@ -530,52 +538,52 @@ def dump_uri_instance(u, nodeid, secret, out, show_header=True): elif isinstance(u, uri.WriteableSSKFileURI): # SDMF if show_header: print("SDMF Writeable URI:", file=out) - print(" writekey:", unicode(base32.b2a(u.writekey), "ascii"), file=out) - print(" readkey:", unicode(base32.b2a(u.readkey), "ascii"), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" writekey:", str(base32.b2a(u.writekey), "ascii"), file=out) + print(" readkey:", str(base32.b2a(u.readkey), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) print(file=out) if nodeid: we = hashutil.ssk_write_enabler_hash(u.writekey, nodeid) - print(" write_enabler:", unicode(base32.b2a(we), "ascii"), file=out) + print(" write_enabler:", str(base32.b2a(we), "ascii"), file=out) print(file=out) _dump_secrets(u.get_storage_index(), secret, nodeid, out) elif isinstance(u, uri.ReadonlySSKFileURI): if show_header: print("SDMF Read-only URI:", file=out) - print(" readkey:", unicode(base32.b2a(u.readkey), "ascii"), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" readkey:", str(base32.b2a(u.readkey), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) elif isinstance(u, uri.SSKVerifierURI): if show_header: print("SDMF Verifier URI:", file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) elif isinstance(u, uri.WriteableMDMFFileURI): # MDMF if show_header: print("MDMF Writeable URI:", file=out) - print(" writekey:", unicode(base32.b2a(u.writekey), "ascii"), file=out) - print(" readkey:", unicode(base32.b2a(u.readkey), "ascii"), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" writekey:", str(base32.b2a(u.writekey), "ascii"), file=out) + print(" readkey:", str(base32.b2a(u.readkey), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) print(file=out) if nodeid: we = hashutil.ssk_write_enabler_hash(u.writekey, nodeid) - print(" write_enabler:", unicode(base32.b2a(we), "ascii"), file=out) + print(" write_enabler:", str(base32.b2a(we), "ascii"), file=out) print(file=out) _dump_secrets(u.get_storage_index(), secret, nodeid, out) elif isinstance(u, uri.ReadonlyMDMFFileURI): if show_header: print("MDMF Read-only URI:", file=out) - print(" readkey:", unicode(base32.b2a(u.readkey), "ascii"), file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" readkey:", str(base32.b2a(u.readkey), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) elif isinstance(u, uri.MDMFVerifierURI): if show_header: print("MDMF Verifier URI:", file=out) - print(" storage index:", unicode(si_b2a(u.get_storage_index()), "ascii"), file=out) - print(" fingerprint:", unicode(base32.b2a(u.fingerprint), "ascii"), file=out) + print(" storage index:", str(si_b2a(u.get_storage_index()), "ascii"), file=out) + print(" fingerprint:", str(base32.b2a(u.fingerprint), "ascii"), file=out) elif isinstance(u, uri.ImmutableDirectoryURI): # CHK-based directory @@ -623,7 +631,7 @@ class FindSharesOptions(BaseOptions): def parseArgs(self, storage_index_s, *nodedirs): from allmydata.util.encodingutil import argv_to_abspath self.si_s = storage_index_s - self.nodedirs = map(argv_to_abspath, nodedirs) + self.nodedirs = list(map(argv_to_abspath, nodedirs)) description = """ Locate all shares for the given storage index. This command looks through one @@ -666,7 +674,7 @@ def find_shares(options): class CatalogSharesOptions(BaseOptions): def parseArgs(self, *nodedirs): from allmydata.util.encodingutil import argv_to_abspath - self.nodedirs = map(argv_to_abspath, nodedirs) + self.nodedirs = list(map(argv_to_abspath, nodedirs)) if not nodedirs: raise usage.UsageError("must specify at least one node directory") @@ -753,7 +761,7 @@ def describe_share(abs_sharefile, si_s, shnum_s, now, out): print("SDMF %s %d/%d %d #%d:%s %d %s" % \ (si_s, k, N, datalen, - seqnum, unicode(base32.b2a(root_hash), "utf-8"), + seqnum, str(base32.b2a(root_hash), "utf-8"), expiration, quote_output(abs_sharefile)), file=out) elif share_type == "MDMF": from allmydata.mutable.layout import MDMFSlotReadProxy @@ -782,7 +790,7 @@ def describe_share(abs_sharefile, si_s, shnum_s, now, out): offsets) = verinfo print("MDMF %s %d/%d %d #%d:%s %d %s" % \ (si_s, k, N, datalen, - seqnum, unicode(base32.b2a(root_hash), "utf-8"), + seqnum, str(base32.b2a(root_hash), "utf-8"), expiration, quote_output(abs_sharefile)), file=out) else: print("UNKNOWN mutable %s" % quote_output(abs_sharefile), file=out) @@ -816,7 +824,7 @@ def describe_share(abs_sharefile, si_s, shnum_s, now, out): ueb_hash = unpacked["UEB_hash"] print("CHK %s %d/%d %d %s %d %s" % (si_s, k, N, filesize, - unicode(ueb_hash, "utf-8"), expiration, + str(ueb_hash, "utf-8"), expiration, quote_output(abs_sharefile)), file=out) else: @@ -990,7 +998,7 @@ def fixOptionsClass(args): class FlogtoolOptions(foolscap_cli.Options): def __init__(self): super(FlogtoolOptions, self).__init__() - self.subCommands = map(fixOptionsClass, self.subCommands) + self.subCommands = list(map(fixOptionsClass, self.subCommands)) def getSynopsis(self): return "Usage: tahoe [global-options] debug flogtool COMMAND [flogtool-options]" diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index eee8bf65b..5572a5760 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -94,6 +94,7 @@ PORTED_MODULES = [ "allmydata.scripts.common_http", "allmydata.scripts.common", "allmydata.scripts.create_node", + "allmydata.scripts.debug", "allmydata.scripts.runner", "allmydata.scripts.types_", "allmydata.stats", From c92bf72437a96d383e3cf272365b2f4f8a7cfc2e Mon Sep 17 00:00:00 2001 From: Itamar Turner-Trauring Date: Mon, 17 May 2021 09:36:43 -0400 Subject: [PATCH 9/9] Add missing comma. --- src/allmydata/util/_python3.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/allmydata/util/_python3.py b/src/allmydata/util/_python3.py index 8190949e1..338dd9423 100644 --- a/src/allmydata/util/_python3.py +++ b/src/allmydata/util/_python3.py @@ -92,7 +92,7 @@ PORTED_MODULES = [ "allmydata.nodemaker", "allmydata.scripts", "allmydata.scripts.admin", - "allmydata.scripts.backupdb" + "allmydata.scripts.backupdb", "allmydata.scripts.cli", "allmydata.scripts.common_http", "allmydata.scripts.common",