Port to Python 3.
This commit is contained in:
parent
2b557287c8
commit
dc818757b6
@ -2,7 +2,13 @@
|
||||
"""
|
||||
I contain the client-side code which speaks to storage servers, in particular
|
||||
the foolscap-based server implemented in src/allmydata/storage/*.py .
|
||||
|
||||
Ported to Python 3.
|
||||
"""
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
# roadmap:
|
||||
#
|
||||
@ -28,7 +34,10 @@ the foolscap-based server implemented in src/allmydata/storage/*.py .
|
||||
#
|
||||
# 6: implement other sorts of IStorageClient classes: S3, etc
|
||||
|
||||
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 re, time, hashlib
|
||||
|
||||
@ -202,7 +211,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
# information.
|
||||
raise
|
||||
else:
|
||||
if isinstance(server_id, unicode):
|
||||
if isinstance(server_id, str):
|
||||
server_id = server_id.encode("utf-8")
|
||||
self._static_server_ids.add(server_id)
|
||||
self.servers[server_id] = storage_server
|
||||
@ -403,7 +412,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
# connections to only a subset of the servers, which would increase
|
||||
# the chances that we'll put shares in weird places (and not update
|
||||
# existing shares of mutable files). See #374 for more details.
|
||||
for dsc in self.servers.values():
|
||||
for dsc in list(self.servers.values()):
|
||||
dsc.try_to_connect()
|
||||
|
||||
def get_servers_for_psi(self, peer_selection_index):
|
||||
@ -443,7 +452,7 @@ class StorageFarmBroker(service.MultiService):
|
||||
# Upload Results web page). If the Helper is running 1.12 or newer,
|
||||
# it will send pubkeys, but if it's still running 1.11, it will send
|
||||
# tubids. This clause maps the old tubids to our existing servers.
|
||||
for s in self.servers.values():
|
||||
for s in list(self.servers.values()):
|
||||
if isinstance(s, NativeStorageServer):
|
||||
if serverid == s.get_tubid():
|
||||
return s
|
||||
@ -556,7 +565,7 @@ class _FoolscapStorage(object):
|
||||
tubid = base32.a2b(tubid_s)
|
||||
if "permutation-seed-base32" in ann:
|
||||
seed = ann["permutation-seed-base32"]
|
||||
if isinstance(seed, unicode):
|
||||
if isinstance(seed, str):
|
||||
seed = seed.encode("utf-8")
|
||||
ps = base32.a2b(seed)
|
||||
elif re.search(br'^v0-[0-9a-zA-Z]{52}$', server_id):
|
||||
@ -651,7 +660,7 @@ def _storage_from_foolscap_plugin(node_config, config, announcement, get_rref):
|
||||
in getPlugins(IFoolscapStoragePlugin)
|
||||
}
|
||||
storage_options = announcement.get(u"storage-options", [])
|
||||
for plugin_name, plugin_config in config.storage_plugins.items():
|
||||
for plugin_name, plugin_config in list(config.storage_plugins.items()):
|
||||
try:
|
||||
plugin = plugins[plugin_name]
|
||||
except KeyError:
|
||||
@ -758,7 +767,7 @@ class NativeStorageServer(service.MultiService):
|
||||
# Nope
|
||||
pass
|
||||
else:
|
||||
if isinstance(furl, unicode):
|
||||
if isinstance(furl, str):
|
||||
furl = furl.encode("utf-8")
|
||||
# See comment above for the _storage_from_foolscap_plugin case
|
||||
# about passing in get_rref.
|
||||
|
@ -52,6 +52,7 @@ PORTED_MODULES = [
|
||||
"allmydata.introducer.interfaces",
|
||||
"allmydata.monitor",
|
||||
"allmydata.node",
|
||||
"allmydata.storage_client",
|
||||
"allmydata.storage.common",
|
||||
"allmydata.storage.crawler",
|
||||
"allmydata.storage.expirer",
|
||||
|
Loading…
Reference in New Issue
Block a user