mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-06 01:21:43 +00:00
Merge pull request #850 from tahoe-lafs/3463.more-immutable-python-3
Port more immutable modules to Python 3 Fixes ticket:3463
This commit is contained in:
commit
6b85fa6628
0
newsfragments/3463.minor
Normal file
0
newsfragments/3463.minor
Normal file
@ -1,4 +1,17 @@
|
|||||||
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
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
|
||||||
|
|
||||||
|
from functools import reduce
|
||||||
import binascii
|
import binascii
|
||||||
from time import time as now
|
from time import time as now
|
||||||
|
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
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 struct
|
import struct
|
||||||
from zope.interface import implementer
|
from zope.interface import implementer
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
@ -1,3 +1,15 @@
|
|||||||
|
"""
|
||||||
|
Ported to Python 3.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from future.utils import PY2, native_str
|
||||||
|
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 past.builtins import long, unicode
|
from past.builtins import long, unicode
|
||||||
|
|
||||||
import os, time, weakref, itertools
|
import os, time, weakref, itertools
|
||||||
@ -66,7 +78,7 @@ def _serialize_existing_shares(existing_shares):
|
|||||||
return {
|
return {
|
||||||
server: list(shares)
|
server: list(shares)
|
||||||
for (server, shares)
|
for (server, shares)
|
||||||
in existing_shares.iteritems()
|
in existing_shares.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
_EXISTING_SHARES = Field(
|
_EXISTING_SHARES = Field(
|
||||||
@ -79,7 +91,7 @@ def _serialize_happiness_mappings(happiness_mappings):
|
|||||||
return {
|
return {
|
||||||
sharenum: base32.b2a(serverid)
|
sharenum: base32.b2a(serverid)
|
||||||
for (sharenum, serverid)
|
for (sharenum, serverid)
|
||||||
in happiness_mappings.iteritems()
|
in happiness_mappings.items()
|
||||||
}
|
}
|
||||||
|
|
||||||
_HAPPINESS_MAPPINGS = Field(
|
_HAPPINESS_MAPPINGS = Field(
|
||||||
@ -150,7 +162,9 @@ class HelperUploadResults(Copyable, RemoteCopy):
|
|||||||
# note: don't change this string, it needs to match the value used on the
|
# note: don't change this string, it needs to match the value used on the
|
||||||
# helper, and it does *not* need to match the fully-qualified
|
# helper, and it does *not* need to match the fully-qualified
|
||||||
# package/module/class name
|
# package/module/class name
|
||||||
typeToCopy = "allmydata.upload.UploadResults.tahoe.allmydata.com"
|
#
|
||||||
|
# Needs to be native string to make Foolscap happy.
|
||||||
|
typeToCopy = native_str("allmydata.upload.UploadResults.tahoe.allmydata.com")
|
||||||
copytype = typeToCopy
|
copytype = typeToCopy
|
||||||
|
|
||||||
# also, think twice about changing the shape of any existing attribute,
|
# also, think twice about changing the shape of any existing attribute,
|
||||||
@ -283,7 +297,7 @@ class ServerTracker(object):
|
|||||||
#log.msg("%s._got_reply(%s)" % (self, (alreadygot, buckets)))
|
#log.msg("%s._got_reply(%s)" % (self, (alreadygot, buckets)))
|
||||||
(alreadygot, buckets) = alreadygot_and_buckets
|
(alreadygot, buckets) = alreadygot_and_buckets
|
||||||
b = {}
|
b = {}
|
||||||
for sharenum, rref in buckets.items():
|
for sharenum, rref in list(buckets.items()):
|
||||||
bp = self.wbp_class(rref, self._server, self.sharesize,
|
bp = self.wbp_class(rref, self._server, self.sharesize,
|
||||||
self.blocksize,
|
self.blocksize,
|
||||||
self.num_segments,
|
self.num_segments,
|
||||||
@ -780,7 +794,7 @@ class Tahoe2ServerSelector(log.PrefixingLogMixin):
|
|||||||
|
|
||||||
shares_to_ask = set()
|
shares_to_ask = set()
|
||||||
servermap = self._share_placements
|
servermap = self._share_placements
|
||||||
for shnum, tracker_id in servermap.items():
|
for shnum, tracker_id in list(servermap.items()):
|
||||||
if tracker_id == None:
|
if tracker_id == None:
|
||||||
continue
|
continue
|
||||||
if tracker.get_serverid() == tracker_id:
|
if tracker.get_serverid() == tracker_id:
|
||||||
@ -1574,7 +1588,7 @@ class AssistedUploader(object):
|
|||||||
# abbreviated), so if we detect old results, just clobber them.
|
# abbreviated), so if we detect old results, just clobber them.
|
||||||
|
|
||||||
sharemap = upload_results.sharemap
|
sharemap = upload_results.sharemap
|
||||||
if str in [type(v) for v in sharemap.values()]:
|
if any(isinstance(v, (bytes, unicode)) for v in sharemap.values()):
|
||||||
upload_results.sharemap = None
|
upload_results.sharemap = None
|
||||||
|
|
||||||
def _build_verifycap(self, helper_upload_results):
|
def _build_verifycap(self, helper_upload_results):
|
||||||
|
@ -42,8 +42,11 @@ PORTED_MODULES = [
|
|||||||
"allmydata.immutable.downloader.share",
|
"allmydata.immutable.downloader.share",
|
||||||
"allmydata.immutable.downloader.status",
|
"allmydata.immutable.downloader.status",
|
||||||
"allmydata.immutable.encode",
|
"allmydata.immutable.encode",
|
||||||
|
"allmydata.immutable.filenode",
|
||||||
"allmydata.immutable.happiness_upload",
|
"allmydata.immutable.happiness_upload",
|
||||||
|
"allmydata.immutable.layout",
|
||||||
"allmydata.immutable.literal",
|
"allmydata.immutable.literal",
|
||||||
|
"allmydata.immutable.upload",
|
||||||
"allmydata.interfaces",
|
"allmydata.interfaces",
|
||||||
"allmydata.introducer.interfaces",
|
"allmydata.introducer.interfaces",
|
||||||
"allmydata.monitor",
|
"allmydata.monitor",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user