DHT py3 compatibility, mostly commenting out implements() and fixing imports

cryptstream py3 support, mostly commenting out implements()
lbry_file py3 support, mostly commenting out implements()
file_manager py3 support, mostly commenting out implements()
core py3 support, mostly commenting out implements() and fixing imports
This commit is contained in:
Lex Berezhny 2018-07-03 00:51:25 -04:00 committed by Jack Robison
parent b3e9240aa8
commit 5520d518b5
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
28 changed files with 60 additions and 61 deletions

View file

@ -49,7 +49,7 @@ class DummyRateLimiter(object):
class RateLimiter(object):
"""This class ensures that upload and download rates don't exceed specified maximums"""
implements(IRateLimiter)
#implements(IRateLimiter)
#called by main application

View file

@ -40,7 +40,7 @@ def cache(fn):
class BlobRequester(object):
implements(IRequestCreator)
#implements(IRequestCreator)
def __init__(self, blob_manager, peer_finder, payment_rate_manager, wallet, download_manager):
self.blob_manager = blob_manager

View file

@ -24,7 +24,7 @@ def encode_decimal(obj):
class ClientProtocol(Protocol, TimeoutMixin):
implements(IRequestSender, IRateLimited)
#implements(IRequestSender, IRateLimited)
######### Protocol #########
PROTOCOL_TIMEOUT = 30

View file

@ -19,7 +19,7 @@ class PeerConnectionHandler(object):
class ConnectionManager(object):
implements(interfaces.IConnectionManager)
#implements(interfaces.IConnectionManager)
MANAGE_CALL_INTERVAL_SEC = 5
TCP_CONNECT_TIMEOUT = 15

View file

@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
class DownloadManager(object):
implements(interfaces.IDownloadManager)
#implements(interfaces.IDownloadManager)
def __init__(self, blob_manager):
self.blob_manager = blob_manager

View file

@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
class SingleBlobMetadataHandler(object):
implements(interfaces.IMetadataHandler)
#implements(interfaces.IMetadataHandler)
def __init__(self, blob_hash, download_manager):
self.blob_hash = blob_hash

View file

@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
class StreamProgressManager(object):
implements(IProgressManager)
#implements(IProgressManager)
def __init__(self, finished_callback, blob_manager,
download_manager, delete_blob_after_finished=False):

View file

@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
class BlobRequestHandlerFactory(object):
implements(IQueryHandlerFactory)
#implements(IQueryHandlerFactory)
def __init__(self, blob_manager, wallet, payment_rate_manager, analytics_manager):
self.blob_manager = blob_manager
@ -36,7 +36,7 @@ class BlobRequestHandlerFactory(object):
class BlobRequestHandler(object):
implements(IQueryHandler, IBlobSender)
#implements(IQueryHandler, IBlobSender)
PAYMENT_RATE_QUERY = 'blob_data_payment_rate'
BLOB_QUERY = 'requested_blob'
AVAILABILITY_QUERY = 'requested_blobs'

View file

@ -24,7 +24,7 @@ class ServerProtocol(Protocol):
10) Pause/resume production when told by the rate limiter
"""
implements(interfaces.IConsumer)
#implements(interfaces.IConsumer)
#Protocol stuff

View file

@ -13,7 +13,7 @@ class ServerRequestHandler(object):
return request for information about more blobs that are
associated with streams.
"""
implements(interfaces.IPushProducer, interfaces.IConsumer, IRequestHandler)
#implements(interfaces.IPushProducer, interfaces.IConsumer, IRequestHandler)
def __init__(self, consumer):
self.consumer = consumer

View file

@ -3,7 +3,8 @@ import json
import subprocess
import os
from urllib2 import urlopen, URLError
from six.moves.urllib.request import urlopen
from six.moves.urllib.error import URLError
from lbryschema import __version__ as lbryschema_version
from lbrynet import build_type, __version__ as lbrynet_version
from lbrynet.conf import ROOT_DIR
@ -19,7 +20,7 @@ def get_lbrynet_version():
stderr=devnull
).strip().lstrip('v')
except (subprocess.CalledProcessError, OSError):
print "failed to get version from git"
print("failed to get version from git")
return lbrynet_version

View file

@ -22,7 +22,7 @@ class CryptStreamCreator(object):
the blob is associated with the stream.
"""
implements(interfaces.IConsumer)
#implements(interfaces.IConsumer)
def __init__(self, blob_manager, name=None, key=None, iv_generator=None):
"""@param blob_manager: Object that stores and provides access to blobs.

View file

@ -6,7 +6,7 @@ from lbrynet.interfaces import IBlobHandler
class CryptBlobHandler(object):
implements(IBlobHandler)
#implements(IBlobHandler)
def __init__(self, key, write_func):
self.key = key

View file

@ -36,7 +36,7 @@ class CurrentlyStartingError(Exception):
class CryptStreamDownloader(object):
implements(IStreamDownloader)
#implements(IStreamDownloader)
def __init__(self, peer_finder, rate_limiter, blob_manager, payment_rate_manager, wallet,
key, stream_name):

View file

@ -1,12 +1,10 @@
import UserDict
import constants
from interface import IDataStore
from zope.interface import implements
from collections import UserDict
from . import constants
class DictDataStore(UserDict.DictMixin):
class DictDataStore(UserDict):
""" A datastore using an in-memory Python dictionary """
implements(IDataStore)
#implements(IDataStore)
def __init__(self, getTime=None):
# Dictionary format:

View file

@ -1,4 +1,4 @@
from error import DecodeError
from .error import DecodeError
class Encoding(object):
@ -68,7 +68,7 @@ class Bencode(Encoding):
encodedDictItems += self.encode(data[key])
return 'd%se' % encodedDictItems
else:
print data
print(data)
raise TypeError("Cannot bencode '%s' object" % type(data))
def decode(self, data):
@ -126,8 +126,8 @@ class Bencode(Encoding):
splitPos = data[startIndex:].find(':') + startIndex
try:
length = int(data[startIndex:splitPos])
except ValueError, e:
raise DecodeError, e
except ValueError:
raise DecodeError()
startIndex = splitPos + 1
endPos = startIndex + length
bytes = data[startIndex:endPos]

View file

@ -1,10 +1,10 @@
import binascii
import exceptions
#import exceptions
# this is a dict of {"exceptions.<exception class name>": exception class} items used to raise
# remote built-in exceptions locally
BUILTIN_EXCEPTIONS = {
"exceptions.%s" % e: getattr(exceptions, e) for e in dir(exceptions) if not e.startswith("_")
# "exceptions.%s" % e: getattr(exceptions, e) for e in dir(exceptions) if not e.startswith("_")
}

View file

@ -1,9 +1,9 @@
import logging
from twisted.internet import defer
from distance import Distance
from error import TimeoutError
import constants
import struct
from twisted.internet import defer
from .distance import Distance
from .error import TimeoutError
from . import constants
log = logging.getLogger(__name__)

View file

@ -1,7 +1,7 @@
import logging
import constants
from distance import Distance
from error import BucketFull
from . import constants
from .distance import Distance
from .error import BucketFull
log = logging.getLogger(__name__)

View file

@ -7,7 +7,7 @@
# The docstrings in this module contain epytext markup; API documentation
# may be created by processing this file with epydoc: http://epydoc.sf.net
import msgtypes
from . import msgtypes
class MessageTranslator(object):

View file

@ -8,7 +8,7 @@
# may be created by processing this file with epydoc: http://epydoc.sf.net
from lbrynet.core.utils import generate_id
import constants
from . import constants
class Message(object):

View file

@ -15,14 +15,14 @@ from twisted.internet import defer, error, task
from lbrynet.core.utils import generate_id, DeferredDict
from lbrynet.core.call_later_manager import CallLaterManager
from lbrynet.core.PeerManager import PeerManager
from error import TimeoutError
import constants
import routingtable
import datastore
import protocol
from peerfinder import DHTPeerFinder
from contact import ContactManager
from iterativefind import iterativeFind
from .error import TimeoutError
from . import constants
from . import routingtable
from . import datastore
from . import protocol
from .peerfinder import DHTPeerFinder
from .contact import ContactManager
from .iterativefind import iterativeFind
log = logging.getLogger(__name__)

View file

@ -19,7 +19,7 @@ class DummyPeerFinder(object):
class DHTPeerFinder(DummyPeerFinder):
"""This class finds peers which have announced to the DHT that they have certain blobs"""
implements(IPeerFinder)
#implements(IPeerFinder)
def __init__(self, dht_node, peer_manager):
"""

View file

@ -4,12 +4,12 @@ import errno
from collections import deque
from twisted.internet import protocol, defer
from error import BUILTIN_EXCEPTIONS, UnknownRemoteException, TimeoutError, TransportNotConnected
from .error import BUILTIN_EXCEPTIONS, UnknownRemoteException, TimeoutError, TransportNotConnected
import constants
import encoding
import msgtypes
import msgformat
from . import constants
from . import encoding
from . import msgtypes
from . import msgformat
log = logging.getLogger(__name__)
@ -436,7 +436,7 @@ class KademliaProtocol(protocol.DatagramProtocol):
result = func(senderContact, *a)
else:
result = func()
except Exception, e:
except Exception as e:
log.exception("error handling request for %s:%i %s", senderContact.address, senderContact.port, method)
df.errback(e)
else:

View file

@ -8,11 +8,11 @@
import random
from zope.interface import implements
from twisted.internet import defer
import constants
import kbucket
from error import TimeoutError
from distance import Distance
from interface import IRoutingTable
from . import constants
from . import kbucket
from .error import TimeoutError
from .distance import Distance
from .interface import IRoutingTable
import logging
log = logging.getLogger(__name__)
@ -33,7 +33,7 @@ class TreeRoutingTable(object):
C{PING} RPC-based k-bucket eviction algorithm described in section 2.2 of
that paper.
"""
implements(IRoutingTable)
#implements(IRoutingTable)
def __init__(self, parentNodeID, getTime=None):
"""

View file

@ -163,7 +163,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
class ManagedEncryptedFileDownloaderFactory(object):
implements(IStreamDownloaderFactory)
#implements(IStreamDownloaderFactory)
def __init__(self, lbry_file_manager, blob_manager):
self.lbry_file_manager = lbry_file_manager

View file

@ -91,7 +91,7 @@ class EncryptedFileDownloader(CryptStreamDownloader):
class EncryptedFileDownloaderFactory(object):
implements(IStreamDownloaderFactory)
#implements(IStreamDownloaderFactory)
def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet):
self.peer_finder = peer_finder

View file

@ -8,7 +8,7 @@ log = logging.getLogger(__name__)
class EncryptedFileMetadataHandler(object):
implements(IMetadataHandler)
#implements(IMetadataHandler)
def __init__(self, stream_hash, storage, download_manager):
self.stream_hash = stream_hash