No longer inheriting from object and added proper use of super().
This commit is contained in:
parent
607677f98f
commit
4ece422f48
75 changed files with 186 additions and 191 deletions
|
@ -24,7 +24,7 @@ BLOB_BYTES_UPLOADED = 'Blob Bytes Uploaded'
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Manager(object):
|
||||
class Manager:
|
||||
def __init__(self, analytics_api, context=None, installation_id=None, session_id=None):
|
||||
self.analytics_api = analytics_api
|
||||
self._tracked_data = collections.defaultdict(list)
|
||||
|
@ -219,7 +219,7 @@ class Manager(object):
|
|||
callback(maybe_deferred, *args, **kwargs)
|
||||
|
||||
|
||||
class Api(object):
|
||||
class Api:
|
||||
def __init__(self, cookies, url, write_key, enabled):
|
||||
self.cookies = cookies
|
||||
self.url = url
|
||||
|
|
|
@ -13,7 +13,7 @@ log = logging.getLogger(__name__)
|
|||
MAX_BLOB_SIZE = 2 * 2 ** 20
|
||||
|
||||
|
||||
class BlobFile(object):
|
||||
class BlobFile:
|
||||
"""
|
||||
A chunk of data available on the network which is specified by a hashsum
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BlobFileCreator(object):
|
||||
class BlobFileCreator:
|
||||
"""
|
||||
This class is used to create blobs on the local filesystem
|
||||
when we do not know the blob hash beforehand (i.e, when creating
|
||||
|
|
|
@ -3,7 +3,7 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HashBlobReader(object):
|
||||
class HashBlobReader:
|
||||
"""
|
||||
This is a file like reader class that supports
|
||||
read(size) and close()
|
||||
|
|
|
@ -7,7 +7,7 @@ from lbrynet.core.cryptoutils import get_lbry_hash_obj
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HashBlobWriter(object):
|
||||
class HashBlobWriter:
|
||||
def __init__(self, length_getter, finished_cb):
|
||||
self.write_handle = BytesIO()
|
||||
self.length_getter = length_getter
|
||||
|
|
|
@ -164,11 +164,11 @@ class Env(envparse.Env):
|
|||
self._convert_key(key): self._convert_value(value)
|
||||
for key, value in schema.items()
|
||||
}
|
||||
envparse.Env.__init__(self, **my_schema)
|
||||
super().__init__(**my_schema)
|
||||
|
||||
def __call__(self, key, *args, **kwargs):
|
||||
my_key = self._convert_key(key)
|
||||
return super(Env, self).__call__(my_key, *args, **kwargs)
|
||||
return super().__call__(my_key, *args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def _convert_key(key):
|
||||
|
@ -289,7 +289,7 @@ ADJUSTABLE_SETTINGS = {
|
|||
}
|
||||
|
||||
|
||||
class Config(object):
|
||||
class Config:
|
||||
def __init__(self, fixed_defaults, adjustable_defaults, persisted_settings=None,
|
||||
environment=None, cli_settings=None):
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ from decimal import Decimal
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BlobAvailabilityTracker(object):
|
||||
class BlobAvailabilityTracker:
|
||||
"""
|
||||
Class to track peer counts for known blobs, and to discover new popular blobs
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class BlobInfo(object):
|
||||
class BlobInfo:
|
||||
"""
|
||||
This structure is used to represent the metadata of a blob.
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbrynet.blob.creator import BlobFileCreator
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DiskBlobManager(object):
|
||||
class DiskBlobManager:
|
||||
def __init__(self, blob_dir, storage, node_datastore=None):
|
||||
"""
|
||||
This class stores blobs on the hard disk
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DownloadOptionChoice(object):
|
||||
class DownloadOptionChoice:
|
||||
"""A possible choice that can be picked for some option.
|
||||
|
||||
An option can have one or more choices that can be picked from.
|
||||
|
@ -10,7 +10,7 @@ class DownloadOptionChoice(object):
|
|||
self.bool_options_description = bool_options_description
|
||||
|
||||
|
||||
class DownloadOption(object):
|
||||
class DownloadOption:
|
||||
"""An option for a user to select a value from several different choices."""
|
||||
def __init__(self, option_types, long_description, short_description, default_value,
|
||||
default_value_description):
|
||||
|
|
|
@ -12,19 +12,19 @@ class DownloadCanceledError(Exception):
|
|||
|
||||
class DownloadSDTimeout(Exception):
|
||||
def __init__(self, download):
|
||||
Exception.__init__(self, 'Failed to download sd blob {} within timeout'.format(download))
|
||||
super().__init__('Failed to download sd blob {} within timeout'.format(download))
|
||||
self.download = download
|
||||
|
||||
|
||||
class DownloadTimeoutError(Exception):
|
||||
def __init__(self, download):
|
||||
Exception.__init__(self, 'Failed to download {} within timeout'.format(download))
|
||||
super().__init__('Failed to download {} within timeout'.format(download))
|
||||
self.download = download
|
||||
|
||||
|
||||
class DownloadDataTimeout(Exception):
|
||||
def __init__(self, download):
|
||||
Exception.__init__(self, 'Failed to download data blobs for sd hash '
|
||||
super().__init__('Failed to download data blobs for sd hash '
|
||||
'{} within timeout'.format(download))
|
||||
self.download = download
|
||||
|
||||
|
@ -55,39 +55,39 @@ class KeyFeeAboveMaxAllowed(Exception):
|
|||
|
||||
class InvalidExchangeRateResponse(Exception):
|
||||
def __init__(self, source, reason):
|
||||
Exception.__init__(self, 'Failed to get exchange rate from {}:{}'.format(source, reason))
|
||||
super().__init__('Failed to get exchange rate from {}:{}'.format(source, reason))
|
||||
self.source = source
|
||||
self.reason = reason
|
||||
|
||||
|
||||
class UnknownNameError(Exception):
|
||||
def __init__(self, name):
|
||||
Exception.__init__(self, 'Name {} is unknown'.format(name))
|
||||
super().__init__('Name {} is unknown'.format(name))
|
||||
self.name = name
|
||||
|
||||
|
||||
class UnknownClaimID(Exception):
|
||||
def __init__(self, claim_id):
|
||||
Exception.__init__(self, 'Claim {} is unknown'.format(claim_id))
|
||||
super().__init__('Claim {} is unknown'.format(claim_id))
|
||||
self.claim_id = claim_id
|
||||
|
||||
|
||||
class UnknownURI(Exception):
|
||||
def __init__(self, uri):
|
||||
Exception.__init__(self, 'URI {} cannot be resolved'.format(uri))
|
||||
super().__init__('URI {} cannot be resolved'.format(uri))
|
||||
self.name = uri
|
||||
|
||||
class UnknownOutpoint(Exception):
|
||||
def __init__(self, outpoint):
|
||||
Exception.__init__(self, 'Outpoint {} cannot be resolved'.format(outpoint))
|
||||
super().__init__('Outpoint {} cannot be resolved'.format(outpoint))
|
||||
self.outpoint = outpoint
|
||||
|
||||
class InvalidName(Exception):
|
||||
def __init__(self, name, invalid_characters):
|
||||
self.name = name
|
||||
self.invalid_characters = invalid_characters
|
||||
Exception.__init__(
|
||||
self, 'URI contains invalid characters: {}'.format(','.join(invalid_characters)))
|
||||
super().__init__(
|
||||
'URI contains invalid characters: {}'.format(','.join(invalid_characters)))
|
||||
|
||||
|
||||
class UnknownStreamTypeError(Exception):
|
||||
|
@ -105,7 +105,7 @@ class InvalidStreamDescriptorError(Exception):
|
|||
class InvalidStreamInfoError(Exception):
|
||||
def __init__(self, name, stream_info):
|
||||
msg = '{} has claim with invalid stream info: {}'.format(name, stream_info)
|
||||
Exception.__init__(self, msg)
|
||||
super().__init__(msg)
|
||||
self.name = name
|
||||
self.stream_info = stream_info
|
||||
|
||||
|
@ -159,14 +159,14 @@ class NegotiationError(Exception):
|
|||
class InvalidCurrencyError(Exception):
|
||||
def __init__(self, currency):
|
||||
self.currency = currency
|
||||
Exception.__init__(
|
||||
self, 'Invalid currency: {} is not a supported currency.'.format(currency))
|
||||
super().__init__(
|
||||
'Invalid currency: {} is not a supported currency.'.format(currency))
|
||||
|
||||
|
||||
class NoSuchDirectoryError(Exception):
|
||||
def __init__(self, directory):
|
||||
self.directory = directory
|
||||
Exception.__init__(self, 'No such directory {}'.format(directory))
|
||||
super().__init__('No such directory {}'.format(directory))
|
||||
|
||||
|
||||
class ComponentStartConditionNotMet(Exception):
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
class Offer(object):
|
||||
class Offer:
|
||||
"""A rate offer to download blobs from a host."""
|
||||
|
||||
RATE_ACCEPTED = "RATE_ACCEPTED"
|
||||
|
|
|
@ -3,14 +3,14 @@ from lbrynet import conf
|
|||
from decimal import Decimal
|
||||
|
||||
|
||||
class BasePaymentRateManager(object):
|
||||
class BasePaymentRateManager:
|
||||
def __init__(self, rate=None, info_rate=None):
|
||||
self.min_blob_data_payment_rate = rate if rate is not None else conf.settings['data_rate']
|
||||
self.min_blob_info_payment_rate = (
|
||||
info_rate if info_rate is not None else conf.settings['min_info_rate'])
|
||||
|
||||
|
||||
class PaymentRateManager(object):
|
||||
class PaymentRateManager:
|
||||
def __init__(self, base, rate=None):
|
||||
"""
|
||||
@param base: a BasePaymentRateManager
|
||||
|
@ -36,7 +36,7 @@ class PaymentRateManager(object):
|
|||
self.points_paid += amount
|
||||
|
||||
|
||||
class NegotiatedPaymentRateManager(object):
|
||||
class NegotiatedPaymentRateManager:
|
||||
def __init__(self, base, availability_tracker, generous=None):
|
||||
"""
|
||||
@param base: a BasePaymentRateManager
|
||||
|
@ -84,7 +84,7 @@ class NegotiatedPaymentRateManager(object):
|
|||
return False
|
||||
|
||||
|
||||
class OnlyFreePaymentsManager(object):
|
||||
class OnlyFreePaymentsManager:
|
||||
def __init__(self, **kwargs):
|
||||
"""
|
||||
A payment rate manager that will only ever accept and offer a rate of 0.0,
|
||||
|
|
|
@ -3,7 +3,7 @@ from collections import defaultdict
|
|||
from lbrynet.core import utils
|
||||
|
||||
# Do not create this object except through PeerManager
|
||||
class Peer(object):
|
||||
class Peer:
|
||||
def __init__(self, host, port):
|
||||
self.host = host
|
||||
self.port = port
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from lbrynet.core.Peer import Peer
|
||||
|
||||
|
||||
class PeerManager(object):
|
||||
class PeerManager:
|
||||
def __init__(self):
|
||||
self.peers = []
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ def get_default_price_model(blob_tracker, base_price, **kwargs):
|
|||
return MeanAvailabilityWeightedPrice(blob_tracker, base_price, **kwargs)
|
||||
|
||||
|
||||
class ZeroPrice(object):
|
||||
class ZeroPrice:
|
||||
def __init__(self):
|
||||
self.base_price = 0.0
|
||||
|
||||
|
@ -17,7 +17,7 @@ class ZeroPrice(object):
|
|||
return 0.0
|
||||
|
||||
|
||||
class MeanAvailabilityWeightedPrice(object):
|
||||
class MeanAvailabilityWeightedPrice:
|
||||
"""Calculate mean-blob-availability and stream-position weighted price for a blob
|
||||
|
||||
Attributes:
|
||||
|
|
|
@ -6,7 +6,7 @@ from twisted.internet import task
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DummyRateLimiter(object):
|
||||
class DummyRateLimiter:
|
||||
def __init__(self):
|
||||
self.dl_bytes_this_second = 0
|
||||
self.ul_bytes_this_second = 0
|
||||
|
@ -44,7 +44,7 @@ class DummyRateLimiter(object):
|
|||
self.total_ul_bytes += num_bytes
|
||||
|
||||
|
||||
class RateLimiter(object):
|
||||
class RateLimiter:
|
||||
"""This class ensures that upload and download rates don't exceed specified maximums"""
|
||||
|
||||
#implements(IRateLimiter)
|
||||
|
|
|
@ -19,7 +19,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
class SinglePeerFinder(DummyPeerFinder):
|
||||
def __init__(self, peer):
|
||||
DummyPeerFinder.__init__(self)
|
||||
super().__init__()
|
||||
self.peer = peer
|
||||
|
||||
def find_peers_for_blob(self, blob_hash, timeout=None, filter_self=False):
|
||||
|
@ -28,7 +28,7 @@ class SinglePeerFinder(DummyPeerFinder):
|
|||
|
||||
class BlobCallback(BlobFile):
|
||||
def __init__(self, blob_dir, blob_hash, timeout):
|
||||
BlobFile.__init__(self, blob_dir, blob_hash)
|
||||
super().__init__(blob_dir, blob_hash)
|
||||
self.callback = defer.Deferred()
|
||||
reactor.callLater(timeout, self._cancel)
|
||||
|
||||
|
@ -43,7 +43,7 @@ class BlobCallback(BlobFile):
|
|||
return result
|
||||
|
||||
|
||||
class SingleBlobDownloadManager(object):
|
||||
class SingleBlobDownloadManager:
|
||||
def __init__(self, blob):
|
||||
self.blob = blob
|
||||
|
||||
|
@ -57,7 +57,7 @@ class SingleBlobDownloadManager(object):
|
|||
return self.blob.blob_hash
|
||||
|
||||
|
||||
class SinglePeerDownloader(object):
|
||||
class SinglePeerDownloader:
|
||||
def __init__(self):
|
||||
self._payment_rate_manager = OnlyFreePaymentsManager()
|
||||
self._rate_limiter = DummyRateLimiter()
|
||||
|
|
|
@ -10,7 +10,7 @@ def get_default_strategy(blob_tracker, **kwargs):
|
|||
return BasicAvailabilityWeightedStrategy(blob_tracker, **kwargs)
|
||||
|
||||
|
||||
class Strategy(object):
|
||||
class Strategy:
|
||||
"""
|
||||
Base for negotiation strategies
|
||||
"""
|
||||
|
@ -109,7 +109,7 @@ class BasicAvailabilityWeightedStrategy(Strategy):
|
|||
base_price=0.0001, alpha=1.0):
|
||||
price_model = MeanAvailabilityWeightedPrice(
|
||||
blob_tracker, base_price=base_price, alpha=alpha)
|
||||
Strategy.__init__(self, price_model, max_rate, min_rate, is_generous)
|
||||
super().__init__(price_model, max_rate, min_rate, is_generous)
|
||||
self._acceleration = Decimal(acceleration) # rate of how quickly to ramp offer
|
||||
self._deceleration = Decimal(deceleration)
|
||||
|
||||
|
@ -140,7 +140,7 @@ class OnlyFreeStrategy(Strategy):
|
|||
implementer(INegotiationStrategy)
|
||||
def __init__(self, *args, **kwargs):
|
||||
price_model = ZeroPrice()
|
||||
Strategy.__init__(self, price_model, 0.0, 0.0, True)
|
||||
super().__init__(price_model, 0.0, 0.0, True)
|
||||
|
||||
def _get_mean_rate(self, rates):
|
||||
return 0.0
|
||||
|
|
|
@ -12,7 +12,7 @@ from lbrynet.core.HTTPBlobDownloader import HTTPBlobDownloader
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StreamDescriptorReader(object):
|
||||
class StreamDescriptorReader:
|
||||
"""Classes which derive from this class read a stream descriptor file return
|
||||
a dictionary containing the fields in the file"""
|
||||
def __init__(self):
|
||||
|
@ -33,7 +33,7 @@ class StreamDescriptorReader(object):
|
|||
class PlainStreamDescriptorReader(StreamDescriptorReader):
|
||||
"""Read a stream descriptor file which is not a blob but a regular file"""
|
||||
def __init__(self, stream_descriptor_filename):
|
||||
StreamDescriptorReader.__init__(self)
|
||||
super().__init__()
|
||||
self.stream_descriptor_filename = stream_descriptor_filename
|
||||
|
||||
def _get_raw_data(self):
|
||||
|
@ -49,7 +49,7 @@ class PlainStreamDescriptorReader(StreamDescriptorReader):
|
|||
class BlobStreamDescriptorReader(StreamDescriptorReader):
|
||||
"""Read a stream descriptor file which is a blob"""
|
||||
def __init__(self, blob):
|
||||
StreamDescriptorReader.__init__(self)
|
||||
super().__init__()
|
||||
self.blob = blob
|
||||
|
||||
def _get_raw_data(self):
|
||||
|
@ -76,7 +76,7 @@ def bytes2unicode(value):
|
|||
return value
|
||||
|
||||
|
||||
class StreamDescriptorWriter(object):
|
||||
class StreamDescriptorWriter:
|
||||
"""Classes which derive from this class write fields from a dictionary
|
||||
of fields to a stream descriptor"""
|
||||
def __init__(self):
|
||||
|
@ -94,7 +94,7 @@ class StreamDescriptorWriter(object):
|
|||
|
||||
class PlainStreamDescriptorWriter(StreamDescriptorWriter):
|
||||
def __init__(self, sd_file_name):
|
||||
StreamDescriptorWriter.__init__(self)
|
||||
super().__init__()
|
||||
self.sd_file_name = sd_file_name
|
||||
|
||||
def _write_stream_descriptor(self, raw_data):
|
||||
|
@ -110,7 +110,7 @@ class PlainStreamDescriptorWriter(StreamDescriptorWriter):
|
|||
|
||||
class BlobStreamDescriptorWriter(StreamDescriptorWriter):
|
||||
def __init__(self, blob_manager):
|
||||
StreamDescriptorWriter.__init__(self)
|
||||
super().__init__()
|
||||
self.blob_manager = blob_manager
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
@ -124,7 +124,7 @@ class BlobStreamDescriptorWriter(StreamDescriptorWriter):
|
|||
defer.returnValue(sd_hash)
|
||||
|
||||
|
||||
class StreamMetadata(object):
|
||||
class StreamMetadata:
|
||||
FROM_BLOB = 1
|
||||
FROM_PLAIN = 2
|
||||
|
||||
|
@ -137,7 +137,7 @@ class StreamMetadata(object):
|
|||
self.source_file = None
|
||||
|
||||
|
||||
class StreamDescriptorIdentifier(object):
|
||||
class StreamDescriptorIdentifier:
|
||||
"""Tries to determine the type of stream described by the stream descriptor using the
|
||||
'stream_type' field. Keeps a list of StreamDescriptorValidators and StreamDownloaderFactorys
|
||||
and returns the appropriate ones based on the type of the stream descriptor given
|
||||
|
@ -407,7 +407,7 @@ def validate_descriptor(stream_info):
|
|||
return True
|
||||
|
||||
|
||||
class EncryptedFileStreamDescriptorValidator(object):
|
||||
class EncryptedFileStreamDescriptorValidator:
|
||||
def __init__(self, raw_info):
|
||||
self.raw_info = raw_info
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ from lbrynet.core.Error import DownloadCanceledError, RequestCanceledError
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReservedPoints(object):
|
||||
class ReservedPoints:
|
||||
def __init__(self, identifier, amount):
|
||||
self.identifier = identifier
|
||||
self.amount = amount
|
||||
|
@ -62,7 +62,7 @@ class ClaimOutpoint(dict):
|
|||
return not self.__eq__(compare)
|
||||
|
||||
|
||||
class Wallet(object):
|
||||
class Wallet:
|
||||
"""This class implements the Wallet interface for the LBRYcrd payment system"""
|
||||
implements(IWallet)
|
||||
|
||||
|
@ -819,7 +819,7 @@ class Wallet(object):
|
|||
|
||||
class LBRYumWallet(Wallet):
|
||||
def __init__(self, storage, config=None):
|
||||
Wallet.__init__(self, storage)
|
||||
super().__init__(storage)
|
||||
self._config = config
|
||||
self.config = make_config(self._config)
|
||||
self.network = None
|
||||
|
@ -1228,7 +1228,7 @@ class LBRYumWallet(Wallet):
|
|||
return not self.wallet.use_encryption
|
||||
|
||||
|
||||
class LBRYcrdAddressRequester(object):
|
||||
class LBRYcrdAddressRequester:
|
||||
implements([IRequestCreator])
|
||||
|
||||
def __init__(self, wallet):
|
||||
|
@ -1266,7 +1266,7 @@ class LBRYcrdAddressRequester(object):
|
|||
return err
|
||||
|
||||
|
||||
class LBRYcrdAddressQueryHandlerFactory(object):
|
||||
class LBRYcrdAddressQueryHandlerFactory:
|
||||
implements(IQueryHandlerFactory)
|
||||
|
||||
def __init__(self, wallet):
|
||||
|
@ -1285,7 +1285,7 @@ class LBRYcrdAddressQueryHandlerFactory(object):
|
|||
return "LBRYcrd Address - an address for receiving payments via LBRYcrd"
|
||||
|
||||
|
||||
class LBRYcrdAddressQueryHandler(object):
|
||||
class LBRYcrdAddressQueryHandler:
|
||||
implements(IQueryHandler)
|
||||
|
||||
def __init__(self, wallet):
|
||||
|
|
|
@ -8,7 +8,7 @@ DELAY_INCREMENT = 0.0001
|
|||
QUEUE_SIZE_THRESHOLD = 100
|
||||
|
||||
|
||||
class CallLaterManager(object):
|
||||
class CallLaterManager:
|
||||
def __init__(self, callLater):
|
||||
"""
|
||||
:param callLater: (IReactorTime.callLater)
|
||||
|
|
|
@ -37,7 +37,7 @@ def cache(fn):
|
|||
return helper
|
||||
|
||||
|
||||
class BlobRequester(object):
|
||||
class BlobRequester:
|
||||
#implements(IRequestCreator)
|
||||
|
||||
def __init__(self, blob_manager, peer_finder, payment_rate_manager, wallet, download_manager):
|
||||
|
@ -193,7 +193,7 @@ class BlobRequester(object):
|
|||
self._peers[peer] += amount
|
||||
|
||||
|
||||
class RequestHelper(object):
|
||||
class RequestHelper:
|
||||
def __init__(self, requestor, peer, protocol, payment_rate_manager):
|
||||
self.requestor = requestor
|
||||
self.peer = peer
|
||||
|
@ -427,7 +427,7 @@ class PriceRequest(RequestHelper):
|
|||
class DownloadRequest(RequestHelper):
|
||||
"""Choose a blob and download it from a peer and also pay the peer for the data."""
|
||||
def __init__(self, requester, peer, protocol, payment_rate_manager, wallet, head_blob_hash):
|
||||
RequestHelper.__init__(self, requester, peer, protocol, payment_rate_manager)
|
||||
super().__init__(requester, peer, protocol, payment_rate_manager)
|
||||
self.wallet = wallet
|
||||
self.head_blob_hash = head_blob_hash
|
||||
|
||||
|
@ -576,7 +576,7 @@ class DownloadRequest(RequestHelper):
|
|||
return reason
|
||||
|
||||
|
||||
class BlobDownloadDetails(object):
|
||||
class BlobDownloadDetails:
|
||||
"""Contains the information needed to make a ClientBlobRequest from an open blob"""
|
||||
def __init__(self, blob, deferred, write_func, cancel_func, peer):
|
||||
self.blob = blob
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from lbrynet.blob.blob_file import MAX_BLOB_SIZE
|
||||
|
||||
|
||||
class ClientRequest(object):
|
||||
class ClientRequest:
|
||||
def __init__(self, request_dict, response_identifier=None):
|
||||
self.request_dict = request_dict
|
||||
self.response_identifier = response_identifier
|
||||
|
@ -9,7 +9,7 @@ class ClientRequest(object):
|
|||
|
||||
class ClientPaidRequest(ClientRequest):
|
||||
def __init__(self, request_dict, response_identifier, max_pay_units):
|
||||
ClientRequest.__init__(self, request_dict, response_identifier)
|
||||
super().__init__(request_dict, response_identifier)
|
||||
self.max_pay_units = max_pay_units
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@ class ClientBlobRequest(ClientPaidRequest):
|
|||
max_pay_units = MAX_BLOB_SIZE
|
||||
else:
|
||||
max_pay_units = blob.length
|
||||
ClientPaidRequest.__init__(self, request_dict, response_identifier, max_pay_units)
|
||||
super().__init__(request_dict, response_identifier, max_pay_units)
|
||||
self.write = write_func
|
||||
self.finished_deferred = finished_deferred
|
||||
self.cancel = cancel_func
|
||||
|
|
|
@ -9,14 +9,14 @@ from lbrynet.core import utils
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PeerConnectionHandler(object):
|
||||
class PeerConnectionHandler:
|
||||
def __init__(self, request_creators, factory):
|
||||
self.request_creators = request_creators
|
||||
self.factory = factory
|
||||
self.connection = None
|
||||
|
||||
|
||||
class ConnectionManager(object):
|
||||
class ConnectionManager:
|
||||
#implements(interfaces.IConnectionManager)
|
||||
MANAGE_CALL_INTERVAL_SEC = 5
|
||||
TCP_CONNECT_TIMEOUT = 15
|
||||
|
|
|
@ -5,7 +5,7 @@ from twisted.internet import defer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DownloadManager(object):
|
||||
class DownloadManager:
|
||||
#implements(interfaces.IDownloadManager)
|
||||
|
||||
def __init__(self, blob_manager):
|
||||
|
|
|
@ -12,7 +12,7 @@ from twisted.internet.task import LoopingCall
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SingleBlobMetadataHandler(object):
|
||||
class SingleBlobMetadataHandler:
|
||||
#implements(interfaces.IMetadataHandler)
|
||||
|
||||
def __init__(self, blob_hash, download_manager):
|
||||
|
@ -29,7 +29,7 @@ class SingleBlobMetadataHandler(object):
|
|||
return 0
|
||||
|
||||
|
||||
class SingleProgressManager(object):
|
||||
class SingleProgressManager:
|
||||
def __init__(self, download_manager, finished_callback, timeout_callback, timeout):
|
||||
self.finished_callback = finished_callback
|
||||
self.timeout_callback = timeout_callback
|
||||
|
@ -72,7 +72,7 @@ class SingleProgressManager(object):
|
|||
return [b for b in blobs.values() if not b.get_is_verified()]
|
||||
|
||||
|
||||
class DummyBlobHandler(object):
|
||||
class DummyBlobHandler:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
@ -80,7 +80,7 @@ class DummyBlobHandler(object):
|
|||
pass
|
||||
|
||||
|
||||
class StandaloneBlobDownloader(object):
|
||||
class StandaloneBlobDownloader:
|
||||
def __init__(self, blob_hash, blob_manager, peer_finder,
|
||||
rate_limiter, payment_rate_manager, wallet,
|
||||
timeout=None):
|
||||
|
|
|
@ -5,7 +5,7 @@ from twisted.internet import defer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StreamProgressManager(object):
|
||||
class StreamProgressManager:
|
||||
#implements(IProgressManager)
|
||||
|
||||
def __init__(self, finished_callback, blob_manager,
|
||||
|
@ -80,7 +80,7 @@ class StreamProgressManager(object):
|
|||
class FullStreamProgressManager(StreamProgressManager):
|
||||
def __init__(self, finished_callback, blob_manager,
|
||||
download_manager, delete_blob_after_finished=False):
|
||||
StreamProgressManager.__init__(self, finished_callback, blob_manager, download_manager,
|
||||
super().__init__(finished_callback, blob_manager, download_manager,
|
||||
delete_blob_after_finished)
|
||||
self.outputting_d = None
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from lbrynet.core import utils
|
|||
|
||||
class HTTPSHandler(logging.Handler):
|
||||
def __init__(self, url, fqdn=False, localname=None, facility=None, cookies=None):
|
||||
logging.Handler.__init__(self)
|
||||
super().__init__()
|
||||
self.url = url
|
||||
self.fqdn = fqdn
|
||||
self.localname = localname
|
||||
|
@ -243,7 +243,7 @@ def configure_twisted():
|
|||
observer.start()
|
||||
|
||||
|
||||
class LoggerNameFilter(object):
|
||||
class LoggerNameFilter:
|
||||
"""Filter a log record based on its name.
|
||||
|
||||
Allows all info level and higher records to pass thru.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class LoopingCallManager(object):
|
||||
class LoopingCallManager:
|
||||
def __init__(self, calls=None):
|
||||
self.calls = calls or {}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from lbrynet.interfaces import IQueryHandlerFactory, IQueryHandler
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BlobAvailabilityHandlerFactory(object):
|
||||
class BlobAvailabilityHandlerFactory:
|
||||
implements(IQueryHandlerFactory)
|
||||
|
||||
def __init__(self, blob_manager):
|
||||
|
@ -26,7 +26,7 @@ class BlobAvailabilityHandlerFactory(object):
|
|||
return "Blob Availability - blobs that are available to be uploaded"
|
||||
|
||||
|
||||
class BlobAvailabilityHandler(object):
|
||||
class BlobAvailabilityHandler:
|
||||
implements(IQueryHandler)
|
||||
|
||||
def __init__(self, blob_manager):
|
||||
|
|
|
@ -10,7 +10,7 @@ from lbrynet.core.Offer import Offer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class BlobRequestHandlerFactory(object):
|
||||
class BlobRequestHandlerFactory:
|
||||
#implements(IQueryHandlerFactory)
|
||||
|
||||
def __init__(self, blob_manager, wallet, payment_rate_manager, analytics_manager):
|
||||
|
@ -33,7 +33,7 @@ class BlobRequestHandlerFactory(object):
|
|||
return "Blob Uploader - uploads blobs"
|
||||
|
||||
|
||||
class BlobRequestHandler(object):
|
||||
class BlobRequestHandler:
|
||||
#implements(IQueryHandler, IBlobSender)
|
||||
PAYMENT_RATE_QUERY = 'blob_data_payment_rate'
|
||||
BLOB_QUERY = 'requested_blob'
|
||||
|
|
|
@ -6,7 +6,7 @@ from twisted.internet import defer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ServerRequestHandler(object):
|
||||
class ServerRequestHandler:
|
||||
"""This class handles requests from clients. It can upload blobs and
|
||||
return request for information about more blobs that are
|
||||
associated with streams.
|
||||
|
|
|
@ -155,7 +155,7 @@ def json_dumps_pretty(obj, **kwargs):
|
|||
return json.dumps(obj, sort_keys=True, indent=2, separators=(',', ': '), **kwargs)
|
||||
|
||||
|
||||
class DeferredLockContextManager(object):
|
||||
class DeferredLockContextManager:
|
||||
def __init__(self, lock):
|
||||
self._lock = lock
|
||||
|
||||
|
@ -181,7 +181,7 @@ def DeferredDict(d, consumeErrors=False):
|
|||
defer.returnValue(response)
|
||||
|
||||
|
||||
class DeferredProfiler(object):
|
||||
class DeferredProfiler:
|
||||
def __init__(self):
|
||||
self.profile_results = {}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ backend = default_backend()
|
|||
|
||||
class CryptBlobInfo(BlobInfo):
|
||||
def __init__(self, blob_hash, blob_num, length, iv):
|
||||
BlobInfo.__init__(self, blob_hash, blob_num, length)
|
||||
super().__init__(blob_hash, blob_num, length)
|
||||
self.iv = iv
|
||||
|
||||
def get_dict(self):
|
||||
|
@ -30,7 +30,7 @@ class CryptBlobInfo(BlobInfo):
|
|||
return info
|
||||
|
||||
|
||||
class StreamBlobDecryptor(object):
|
||||
class StreamBlobDecryptor:
|
||||
def __init__(self, blob, key, iv, length):
|
||||
"""
|
||||
This class decrypts blob
|
||||
|
@ -99,7 +99,7 @@ class StreamBlobDecryptor(object):
|
|||
return d
|
||||
|
||||
|
||||
class CryptStreamBlobMaker(object):
|
||||
class CryptStreamBlobMaker:
|
||||
def __init__(self, key, iv, blob_num, blob):
|
||||
"""
|
||||
This class encrypts data and writes it to a new blob
|
||||
|
|
|
@ -12,7 +12,7 @@ from lbrynet.cryptstream.CryptBlob import CryptStreamBlobMaker
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CryptStreamCreator(object):
|
||||
class CryptStreamCreator:
|
||||
"""
|
||||
Create a new stream with blobs encrypted by a symmetric cipher.
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ from twisted.internet import defer
|
|||
from lbrynet.cryptstream.CryptBlob import StreamBlobDecryptor
|
||||
|
||||
|
||||
class CryptBlobHandler(object):
|
||||
class CryptBlobHandler:
|
||||
#implements(IBlobHandler)
|
||||
|
||||
def __init__(self, key, write_func):
|
||||
|
|
|
@ -32,7 +32,7 @@ class CurrentlyStartingError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class CryptStreamDownloader(object):
|
||||
class CryptStreamDownloader:
|
||||
|
||||
#implements(IStreamDownloader)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ class ComponentType(type):
|
|||
return klass
|
||||
|
||||
|
||||
class Component(object, metaclass=ComponentType):
|
||||
class Component(metaclass=ComponentType):
|
||||
"""
|
||||
lbrynet-daemon component helper
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ def get_wallet_config():
|
|||
return config
|
||||
|
||||
|
||||
class ConfigSettings(object):
|
||||
class ConfigSettings:
|
||||
@staticmethod
|
||||
def get_conf_setting(setting_name):
|
||||
return conf.settings[setting_name]
|
||||
|
@ -101,7 +101,7 @@ class DatabaseComponent(Component):
|
|||
component_name = DATABASE_COMPONENT
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.storage = None
|
||||
|
||||
@property
|
||||
|
@ -306,7 +306,7 @@ class WalletComponent(Component):
|
|||
depends_on = [DATABASE_COMPONENT, HEADERS_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.wallet = None
|
||||
|
||||
@property
|
||||
|
@ -329,6 +329,7 @@ class WalletComponent(Component):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def start(self):
|
||||
log.info("Starting torba wallet")
|
||||
storage = self.component_manager.get_component(DATABASE_COMPONENT)
|
||||
lbryschema.BLOCKCHAIN_NAME = conf.settings['blockchain_name']
|
||||
self.wallet = LbryWalletManager.from_old_config(conf.settings)
|
||||
|
@ -346,7 +347,7 @@ class BlobComponent(Component):
|
|||
depends_on = [DATABASE_COMPONENT, DHT_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.blob_manager = None
|
||||
|
||||
@property
|
||||
|
@ -377,7 +378,7 @@ class DHTComponent(Component):
|
|||
depends_on = [UPNP_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.dht_node = None
|
||||
self.upnp_component = None
|
||||
self.external_udp_port = None
|
||||
|
@ -427,7 +428,7 @@ class HashAnnouncerComponent(Component):
|
|||
depends_on = [DHT_COMPONENT, DATABASE_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.hash_announcer = None
|
||||
|
||||
@property
|
||||
|
@ -455,7 +456,7 @@ class RateLimiterComponent(Component):
|
|||
component_name = RATE_LIMITER_COMPONENT
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.rate_limiter = RateLimiter()
|
||||
|
||||
@property
|
||||
|
@ -476,7 +477,7 @@ class StreamIdentifierComponent(Component):
|
|||
depends_on = [DHT_COMPONENT, RATE_LIMITER_COMPONENT, BLOB_COMPONENT, DATABASE_COMPONENT, WALLET_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.sd_identifier = StreamDescriptorIdentifier()
|
||||
|
||||
@property
|
||||
|
@ -510,7 +511,7 @@ class PaymentRateComponent(Component):
|
|||
component_name = PAYMENT_RATE_COMPONENT
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.payment_rate_manager = OnlyFreePaymentsManager()
|
||||
|
||||
@property
|
||||
|
@ -530,7 +531,7 @@ class FileManagerComponent(Component):
|
|||
STREAM_IDENTIFIER_COMPONENT, PAYMENT_RATE_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.file_manager = None
|
||||
|
||||
@property
|
||||
|
@ -570,7 +571,7 @@ class PeerProtocolServerComponent(Component):
|
|||
PAYMENT_RATE_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.lbry_server_port = None
|
||||
|
||||
@property
|
||||
|
@ -622,7 +623,7 @@ class ReflectorComponent(Component):
|
|||
depends_on = [DHT_COMPONENT, BLOB_COMPONENT, FILE_MANAGER_COMPONENT]
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self.reflector_server_port = GCS('reflector_port')
|
||||
self.reflector_server = None
|
||||
|
||||
|
@ -656,7 +657,7 @@ class UPnPComponent(Component):
|
|||
component_name = UPNP_COMPONENT
|
||||
|
||||
def __init__(self, component_manager):
|
||||
Component.__init__(self, component_manager)
|
||||
super().__init__(component_manager)
|
||||
self._int_peer_port = GCS('peer_port')
|
||||
self._int_dht_node_port = GCS('dht_node_port')
|
||||
self.use_upnp = GCS('use_upnp')
|
||||
|
|
|
@ -77,8 +77,7 @@ DIRECTION_ASCENDING = 'asc'
|
|||
DIRECTION_DESCENDING = 'desc'
|
||||
DIRECTIONS = DIRECTION_ASCENDING, DIRECTION_DESCENDING
|
||||
|
||||
|
||||
class IterableContainer(object):
|
||||
class IterableContainer:
|
||||
def __iter__(self):
|
||||
for attr in dir(self):
|
||||
if not attr.startswith("_"):
|
||||
|
@ -91,7 +90,7 @@ class IterableContainer(object):
|
|||
return False
|
||||
|
||||
|
||||
class Checker(object):
|
||||
class Checker:
|
||||
"""The looping calls the daemon runs"""
|
||||
INTERNET_CONNECTION = 'internet_connection_checker', 300
|
||||
# CONNECTION_STATUS = 'connection_status_checker'
|
||||
|
@ -123,7 +122,7 @@ class NoValidSearch(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class CheckInternetConnection(object):
|
||||
class CheckInternetConnection:
|
||||
def __init__(self, daemon):
|
||||
self.daemon = daemon
|
||||
|
||||
|
@ -131,7 +130,7 @@ class CheckInternetConnection(object):
|
|||
self.daemon.connected_to_internet = utils.check_connection()
|
||||
|
||||
|
||||
class AlwaysSend(object):
|
||||
class AlwaysSend:
|
||||
def __init__(self, value_generator, *args, **kwargs):
|
||||
self.value_generator = value_generator
|
||||
self.args = args
|
||||
|
|
|
@ -29,7 +29,7 @@ STREAM_STAGES = [
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class GetStream(object):
|
||||
class GetStream:
|
||||
def __init__(self, sd_identifier, wallet, exchange_rate_manager, blob_manager, peer_finder, rate_limiter,
|
||||
payment_rate_manager, storage, max_key_fee, disable_max_key_fee, data_rate=None, timeout=None):
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ BITTREX_FEE = 0.0025
|
|||
COINBASE_FEE = 0.0 # add fee
|
||||
|
||||
|
||||
class ExchangeRate(object):
|
||||
class ExchangeRate:
|
||||
def __init__(self, market, spot, ts):
|
||||
if not int(time.time()) - ts < 600:
|
||||
raise ValueError('The timestamp is too dated.')
|
||||
|
@ -34,7 +34,7 @@ class ExchangeRate(object):
|
|||
return {'spot': self.spot, 'ts': self.ts}
|
||||
|
||||
|
||||
class MarketFeed(object):
|
||||
class MarketFeed:
|
||||
REQUESTS_TIMEOUT = 20
|
||||
EXCHANGE_RATE_UPDATE_RATE_SEC = 300
|
||||
|
||||
|
@ -96,8 +96,7 @@ class MarketFeed(object):
|
|||
|
||||
class BittrexFeed(MarketFeed):
|
||||
def __init__(self):
|
||||
MarketFeed.__init__(
|
||||
self,
|
||||
super().__init__(
|
||||
"BTCLBC",
|
||||
"Bittrex",
|
||||
"https://bittrex.com/api/v1.1/public/getmarkethistory",
|
||||
|
@ -122,8 +121,7 @@ class BittrexFeed(MarketFeed):
|
|||
|
||||
class LBRYioFeed(MarketFeed):
|
||||
def __init__(self):
|
||||
MarketFeed.__init__(
|
||||
self,
|
||||
super().__init__(
|
||||
"BTCLBC",
|
||||
"lbry.io",
|
||||
"https://api.lbry.io/lbc/exchange_rate",
|
||||
|
@ -140,8 +138,7 @@ class LBRYioFeed(MarketFeed):
|
|||
|
||||
class LBRYioBTCFeed(MarketFeed):
|
||||
def __init__(self):
|
||||
MarketFeed.__init__(
|
||||
self,
|
||||
super().__init__(
|
||||
"USDBTC",
|
||||
"lbry.io",
|
||||
"https://api.lbry.io/lbc/exchange_rate",
|
||||
|
@ -161,8 +158,7 @@ class LBRYioBTCFeed(MarketFeed):
|
|||
|
||||
class CryptonatorBTCFeed(MarketFeed):
|
||||
def __init__(self):
|
||||
MarketFeed.__init__(
|
||||
self,
|
||||
super().__init__(
|
||||
"USDBTC",
|
||||
"cryptonator.com",
|
||||
"https://api.cryptonator.com/api/ticker/usd-btc",
|
||||
|
@ -183,8 +179,7 @@ class CryptonatorBTCFeed(MarketFeed):
|
|||
|
||||
class CryptonatorFeed(MarketFeed):
|
||||
def __init__(self):
|
||||
MarketFeed.__init__(
|
||||
self,
|
||||
super().__init__(
|
||||
"BTCLBC",
|
||||
"cryptonator.com",
|
||||
"https://api.cryptonator.com/api/ticker/btc-lbc",
|
||||
|
@ -203,7 +198,7 @@ class CryptonatorFeed(MarketFeed):
|
|||
return defer.succeed(float(json_response['ticker']['price']))
|
||||
|
||||
|
||||
class ExchangeRateManager(object):
|
||||
class ExchangeRateManager:
|
||||
def __init__(self):
|
||||
self.market_feeds = [
|
||||
LBRYioBTCFeed(),
|
||||
|
|
|
@ -12,7 +12,7 @@ from lbrynet.wallet.account import get_certificate_lookup
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Publisher(object):
|
||||
class Publisher:
|
||||
def __init__(self, blob_manager, payment_rate_manager, storage, lbry_file_manager, wallet, certificate):
|
||||
self.blob_manager = blob_manager
|
||||
self.payment_rate_manager = payment_rate_manager
|
||||
|
|
|
@ -9,7 +9,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
|
||||
@implementer(portal.IRealm)
|
||||
class HttpPasswordRealm(object):
|
||||
class HttpPasswordRealm:
|
||||
def __init__(self, resource):
|
||||
self.resource = resource
|
||||
|
||||
|
@ -21,7 +21,7 @@ class HttpPasswordRealm(object):
|
|||
|
||||
|
||||
@implementer(checkers.ICredentialsChecker)
|
||||
class PasswordChecker(object):
|
||||
class PasswordChecker:
|
||||
credentialInterfaces = (credentials.IUsernamePassword,)
|
||||
|
||||
def __init__(self, passwords):
|
||||
|
|
|
@ -23,11 +23,11 @@ def copy_cookies(cookies):
|
|||
|
||||
class JSONRPCException(Exception):
|
||||
def __init__(self, rpc_error):
|
||||
Exception.__init__(self)
|
||||
super().__init__()
|
||||
self.error = rpc_error
|
||||
|
||||
|
||||
class AuthAPIClient(object):
|
||||
class AuthAPIClient:
|
||||
def __init__(self, key, timeout, connection, count, cookies, url, login_url):
|
||||
self.__api_key = key
|
||||
self.__service_url = login_url
|
||||
|
@ -130,7 +130,7 @@ class AuthAPIClient(object):
|
|||
return cls(api_key, timeout, conn, id_count, cookies, url, service_url)
|
||||
|
||||
|
||||
class LBRYAPIClient(object):
|
||||
class LBRYAPIClient:
|
||||
@staticmethod
|
||||
def get_client():
|
||||
if not conf.settings:
|
||||
|
|
|
@ -27,7 +27,7 @@ log = logging.getLogger(__name__)
|
|||
EMPTY_PARAMS = [{}]
|
||||
|
||||
|
||||
class JSONRPCError(object):
|
||||
class JSONRPCError:
|
||||
# http://www.jsonrpc.org/specification#error_object
|
||||
CODE_PARSE_ERROR = -32700 # Invalid JSON. Error while parsing the JSON text.
|
||||
CODE_INVALID_REQUEST = -32600 # The JSON sent is not a valid Request object.
|
||||
|
@ -129,7 +129,7 @@ class JSONRPCServerType(type):
|
|||
return klass
|
||||
|
||||
|
||||
class AuthorizedBase(object, metaclass=JSONRPCServerType):
|
||||
class AuthorizedBase(metaclass=JSONRPCServerType):
|
||||
|
||||
@staticmethod
|
||||
def deprecated(new_command=None):
|
||||
|
|
|
@ -24,7 +24,7 @@ def generate_key(x=None):
|
|||
return sha(x)
|
||||
|
||||
|
||||
class APIKey(object):
|
||||
class APIKey:
|
||||
def __init__(self, secret, name, expiration=None):
|
||||
self.secret = secret
|
||||
self.name = name
|
||||
|
|
|
@ -85,11 +85,11 @@ def rerun_if_locked(f):
|
|||
|
||||
class SqliteConnection(adbapi.ConnectionPool):
|
||||
def __init__(self, db_path):
|
||||
adbapi.ConnectionPool.__init__(self, 'sqlite3', db_path, check_same_thread=False)
|
||||
super().__init__('sqlite3', db_path, check_same_thread=False)
|
||||
|
||||
@rerun_if_locked
|
||||
def runInteraction(self, interaction, *args, **kw):
|
||||
return adbapi.ConnectionPool.runInteraction(self, interaction, *args, **kw)
|
||||
return super().runInteraction(interaction, *args, **kw)
|
||||
|
||||
@classmethod
|
||||
def set_reactor(cls, reactor):
|
||||
|
|
|
@ -13,7 +13,7 @@ def is_valid_ipv4(address):
|
|||
return False
|
||||
|
||||
|
||||
class _Contact(object):
|
||||
class _Contact:
|
||||
""" Encapsulation for remote contact
|
||||
|
||||
This class contains information on a single remote contact, and also
|
||||
|
@ -167,7 +167,7 @@ class _Contact(object):
|
|||
return _sendRPC
|
||||
|
||||
|
||||
class ContactManager(object):
|
||||
class ContactManager:
|
||||
def __init__(self, get_time=None):
|
||||
if not get_time:
|
||||
from twisted.internet import reactor
|
||||
|
|
|
@ -6,7 +6,7 @@ if sys.version_info > (3,):
|
|||
long = int
|
||||
|
||||
|
||||
class Distance(object):
|
||||
class Distance:
|
||||
"""Calculate the XOR result between two string variables.
|
||||
|
||||
Frequently we re-use one of the points so as an optimization
|
||||
|
|
|
@ -7,7 +7,7 @@ if sys.version_info > (3,):
|
|||
else:
|
||||
raw = lambda x: x
|
||||
|
||||
class Encoding(object):
|
||||
class Encoding:
|
||||
""" Interface for RPC message encoders/decoders
|
||||
|
||||
All encoding implementations used with this library should inherit and
|
||||
|
|
|
@ -37,7 +37,7 @@ class TimeoutError(Exception):
|
|||
msg = 'Timeout connecting to {}'.format(binascii.hexlify(remote_contact_id))
|
||||
else:
|
||||
msg = 'Timeout connecting to uninitialized node'
|
||||
Exception.__init__(self, msg)
|
||||
super().__init__(msg)
|
||||
self.remote_contact_id = remote_contact_id
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbrynet import conf
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DHTHashAnnouncer(object):
|
||||
class DHTHashAnnouncer:
|
||||
def __init__(self, dht_node, storage, concurrent_announcers=None):
|
||||
self.dht_node = dht_node
|
||||
self.storage = storage
|
||||
|
|
|
@ -22,7 +22,7 @@ def expand_peer(compact_peer_info):
|
|||
return (peer_node_id, host, port)
|
||||
|
||||
|
||||
class _IterativeFind(object):
|
||||
class _IterativeFind:
|
||||
# TODO: use polymorphism to search for a value or node
|
||||
# instead of using a find_value flag
|
||||
def __init__(self, node, shortlist, key, rpc, exclude=None):
|
||||
|
|
|
@ -11,7 +11,7 @@ if sys.version_info > (3,):
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class KBucket(object):
|
||||
class KBucket:
|
||||
""" Description - later
|
||||
"""
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
from . import msgtypes
|
||||
|
||||
|
||||
class MessageTranslator(object):
|
||||
class MessageTranslator:
|
||||
""" Interface for RPC message translators/formatters
|
||||
|
||||
Classes inheriting from this should provide a translation services between
|
||||
|
|
|
@ -11,7 +11,7 @@ from lbrynet.core.utils import generate_id
|
|||
from . import constants
|
||||
|
||||
|
||||
class Message(object):
|
||||
class Message:
|
||||
""" Base class for messages - all "unknown" messages use this class """
|
||||
|
||||
def __init__(self, rpcID, nodeID):
|
||||
|
@ -29,7 +29,7 @@ class RequestMessage(Message):
|
|||
def __init__(self, nodeID, method, methodArgs, rpcID=None):
|
||||
if rpcID is None:
|
||||
rpcID = generate_id()[:constants.rpc_id_length]
|
||||
Message.__init__(self, rpcID, nodeID)
|
||||
super().__init__(rpcID, nodeID)
|
||||
self.request = method
|
||||
self.args = methodArgs
|
||||
|
||||
|
@ -38,7 +38,7 @@ class ResponseMessage(Message):
|
|||
""" Message containing the result from a successful RPC request """
|
||||
|
||||
def __init__(self, rpcID, nodeID, response):
|
||||
Message.__init__(self, rpcID, nodeID)
|
||||
super().__init__(rpcID, nodeID)
|
||||
self.response = response
|
||||
|
||||
|
||||
|
@ -46,7 +46,7 @@ class ErrorMessage(ResponseMessage):
|
|||
""" Message containing the error from an unsuccessful RPC request """
|
||||
|
||||
def __init__(self, rpcID, nodeID, exceptionType, errorMessage):
|
||||
ResponseMessage.__init__(self, rpcID, nodeID, errorMessage)
|
||||
super().__init__(rpcID, nodeID, errorMessage)
|
||||
if isinstance(exceptionType, type):
|
||||
exceptionType = ('%s.%s' % (exceptionType.__module__, exceptionType.__name__)).encode()
|
||||
self.exceptionType = exceptionType
|
||||
|
|
|
@ -47,7 +47,7 @@ def rpcmethod(func):
|
|||
return func
|
||||
|
||||
|
||||
class MockKademliaHelper(object):
|
||||
class MockKademliaHelper:
|
||||
def __init__(self, clock=None, callLater=None, resolve=None, listenUDP=None):
|
||||
if not listenUDP or not resolve or not callLater or not clock:
|
||||
from twisted.internet import reactor
|
||||
|
@ -127,7 +127,7 @@ class Node(MockKademliaHelper):
|
|||
@param peerPort: the port at which this node announces it has a blob for
|
||||
"""
|
||||
|
||||
MockKademliaHelper.__init__(self, clock, callLater, resolve, listenUDP)
|
||||
super().__init__(clock, callLater, resolve, listenUDP)
|
||||
self.node_id = node_id or self._generateID()
|
||||
self.port = udpPort
|
||||
self._listen_interface = interface
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbrynet import conf
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DummyPeerFinder(object):
|
||||
class DummyPeerFinder:
|
||||
"""This class finds peers which have announced to the DHT that they have certain blobs"""
|
||||
|
||||
def find_peers_for_blob(self, blob_hash, timeout=None, filter_self=True):
|
||||
|
|
|
@ -15,7 +15,7 @@ from . import msgformat
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PingQueue(object):
|
||||
class PingQueue:
|
||||
"""
|
||||
Schedules a 15 minute delayed ping after a new node sends us a query. This is so the new node gets added to the
|
||||
routing table after having been given enough time for a pinhole to expire.
|
||||
|
|
|
@ -16,7 +16,7 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TreeRoutingTable(object):
|
||||
class TreeRoutingTable:
|
||||
""" This class implements a routing table used by a Node class.
|
||||
|
||||
The Kademlia routing table is a binary tree whFose leaves are k-buckets,
|
||||
|
|
|
@ -24,7 +24,7 @@ class EncryptedFileStreamCreator(CryptStreamCreator):
|
|||
|
||||
def __init__(self, blob_manager, lbry_file_manager, stream_name=None,
|
||||
key=None, iv_generator=None):
|
||||
CryptStreamCreator.__init__(self, blob_manager, stream_name, key, iv_generator)
|
||||
super().__init__(blob_manager, stream_name, key, iv_generator)
|
||||
self.lbry_file_manager = lbry_file_manager
|
||||
self.stream_hash = None
|
||||
self.blob_infos = []
|
||||
|
|
|
@ -37,8 +37,8 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
|||
def __init__(self, rowid, stream_hash, peer_finder, rate_limiter, blob_manager, storage, lbry_file_manager,
|
||||
payment_rate_manager, wallet, download_directory, file_name, stream_name, sd_hash, key,
|
||||
suggested_file_name, download_mirrors=None):
|
||||
EncryptedFileSaver.__init__(
|
||||
self, stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet,
|
||||
super().__init__(
|
||||
stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet,
|
||||
download_directory, key, stream_name, file_name
|
||||
)
|
||||
self.sd_hash = sd_hash
|
||||
|
@ -160,7 +160,7 @@ class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
|||
self.blob_manager, download_manager)
|
||||
|
||||
|
||||
class ManagedEncryptedFileDownloaderFactory(object):
|
||||
class ManagedEncryptedFileDownloaderFactory:
|
||||
#implements(IStreamDownloaderFactory)
|
||||
|
||||
def __init__(self, lbry_file_manager, blob_manager):
|
||||
|
|
|
@ -19,7 +19,7 @@ from lbrynet import conf
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EncryptedFileManager(object):
|
||||
class EncryptedFileManager:
|
||||
"""
|
||||
Keeps track of currently opened LBRY Files, their options, and
|
||||
their LBRY File specific metadata.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class EncryptedFileStatusReport(object):
|
||||
class EncryptedFileStatusReport:
|
||||
def __init__(self, name, num_completed, num_known, running_status):
|
||||
self.name = name
|
||||
self.num_completed = num_completed
|
||||
|
|
|
@ -18,7 +18,7 @@ class EncryptedFileDownloader(CryptStreamDownloader):
|
|||
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
storage, payment_rate_manager, wallet, key, stream_name, file_name):
|
||||
CryptStreamDownloader.__init__(self, peer_finder, rate_limiter, blob_manager,
|
||||
super().__init__(peer_finder, rate_limiter, blob_manager,
|
||||
payment_rate_manager, wallet, key, stream_name)
|
||||
self.stream_hash = stream_hash
|
||||
self.storage = storage
|
||||
|
@ -87,7 +87,7 @@ class EncryptedFileDownloader(CryptStreamDownloader):
|
|||
self.storage, download_manager)
|
||||
|
||||
|
||||
class EncryptedFileDownloaderFactory(object):
|
||||
class EncryptedFileDownloaderFactory:
|
||||
#implements(IStreamDownloaderFactory)
|
||||
|
||||
def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet):
|
||||
|
@ -125,7 +125,7 @@ class EncryptedFileDownloaderFactory(object):
|
|||
class EncryptedFileSaver(EncryptedFileDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, storage, payment_rate_manager, wallet,
|
||||
download_directory, key, stream_name, file_name):
|
||||
EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter,
|
||||
super().__init__(stream_hash, peer_finder, rate_limiter,
|
||||
blob_manager, storage, payment_rate_manager,
|
||||
wallet, key, stream_name, file_name)
|
||||
self.download_directory = binascii.unhexlify(download_directory)
|
||||
|
@ -180,7 +180,7 @@ class EncryptedFileSaver(EncryptedFileDownloader):
|
|||
|
||||
class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory):
|
||||
def __init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet, download_directory):
|
||||
EncryptedFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager, storage, wallet)
|
||||
super().__init__(peer_finder, rate_limiter, blob_manager, storage, wallet)
|
||||
self.download_directory = binascii.hexlify(download_directory.encode())
|
||||
|
||||
def _make_downloader(self, stream_hash, payment_rate_manager, stream_info):
|
||||
|
|
|
@ -5,7 +5,7 @@ from twisted.internet import defer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class EncryptedFileMetadataHandler(object):
|
||||
class EncryptedFileMetadataHandler:
|
||||
|
||||
def __init__(self, stream_hash, storage, download_manager):
|
||||
self.stream_hash = stream_hash
|
||||
|
|
|
@ -8,7 +8,7 @@ def add_lbry_file_to_sd_identifier(sd_identifier):
|
|||
EncryptedFileOptions())
|
||||
|
||||
|
||||
class EncryptedFileOptions(object):
|
||||
class EncryptedFileOptions:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ def get_certificate_lookup(tx_or_hash, nout):
|
|||
class Account(BaseAccount):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Account, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.certificates = {}
|
||||
|
||||
def add_certificate_private_key(self, tx_or_hash, nout, private_key):
|
||||
|
@ -73,20 +73,20 @@ class Account(BaseAccount):
|
|||
def get_balance(self, confirmations=6, include_claims=False, **constraints):
|
||||
if not include_claims:
|
||||
constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0})
|
||||
return super(Account, self).get_balance(confirmations, **constraints)
|
||||
return super().get_balance(confirmations, **constraints)
|
||||
|
||||
def get_unspent_outputs(self, include_claims=False, **constraints):
|
||||
if not include_claims:
|
||||
constraints.update({'is_claim': 0, 'is_update': 0, 'is_support': 0})
|
||||
return super(Account, self).get_unspent_outputs(**constraints)
|
||||
return super().get_unspent_outputs(**constraints)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, ledger, d): # type: (torba.baseledger.BaseLedger, Dict) -> BaseAccount
|
||||
account = super(Account, cls).from_dict(ledger, d)
|
||||
account = super().from_dict(ledger, d)
|
||||
account.certificates = d['certificates']
|
||||
return account
|
||||
|
||||
def to_dict(self):
|
||||
d = super(Account, self).to_dict()
|
||||
d = super().to_dict()
|
||||
d['certificates'] = self.certificates
|
||||
return d
|
||||
|
|
|
@ -32,7 +32,7 @@ class WalletDatabase(BaseDatabase):
|
|||
)
|
||||
|
||||
def txo_to_row(self, tx, address, txo):
|
||||
row = super(WalletDatabase, self).txo_to_row(tx, address, txo)
|
||||
row = super().txo_to_row(tx, address, txo)
|
||||
row.update({
|
||||
'is_claim': txo.script.is_claim_name,
|
||||
'is_update': txo.script.is_update_claim,
|
||||
|
|
|
@ -125,13 +125,13 @@ class MainNetLedger(BaseLedger):
|
|||
default_fee_per_name_char = 200000
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MainNetLedger, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fee_per_name_char = self.config.get('fee_per_name_char', self.default_fee_per_name_char)
|
||||
|
||||
def get_transaction_base_fee(self, tx):
|
||||
""" Fee for the transaction header and all outputs; without inputs. """
|
||||
return max(
|
||||
super(MainNetLedger, self).get_transaction_base_fee(tx),
|
||||
super().get_transaction_base_fee(tx),
|
||||
self.get_transaction_claim_name_fee(tx)
|
||||
)
|
||||
|
||||
|
@ -156,7 +156,7 @@ class MainNetLedger(BaseLedger):
|
|||
|
||||
@defer.inlineCallbacks
|
||||
def start(self):
|
||||
yield super(MainNetLedger, self).start()
|
||||
yield super().start()
|
||||
yield defer.DeferredList([
|
||||
a.maybe_migrate_certificates() for a in self.accounts
|
||||
])
|
||||
|
|
|
@ -20,7 +20,7 @@ if six.PY3:
|
|||
buffer = memoryview
|
||||
|
||||
|
||||
class BackwardsCompatibleNetwork(object):
|
||||
class BackwardsCompatibleNetwork:
|
||||
def __init__(self, manager):
|
||||
self.manager = manager
|
||||
|
||||
|
@ -232,19 +232,19 @@ class LbryWalletManager(BaseWalletManager):
|
|||
wallet.save()
|
||||
|
||||
|
||||
class ReservedPoints(object):
|
||||
class ReservedPoints:
|
||||
def __init__(self, identifier, amount):
|
||||
self.identifier = identifier
|
||||
self.amount = amount
|
||||
|
||||
|
||||
class ClientRequest(object):
|
||||
class ClientRequest:
|
||||
def __init__(self, request_dict, response_identifier=None):
|
||||
self.request_dict = request_dict
|
||||
self.response_identifier = response_identifier
|
||||
|
||||
|
||||
class LBRYcrdAddressRequester(object):
|
||||
class LBRYcrdAddressRequester:
|
||||
|
||||
def __init__(self, wallet):
|
||||
self.wallet = wallet
|
||||
|
@ -277,7 +277,7 @@ class LBRYcrdAddressRequester(object):
|
|||
)
|
||||
|
||||
|
||||
class LBRYcrdAddressQueryHandlerFactory(object):
|
||||
class LBRYcrdAddressQueryHandlerFactory:
|
||||
|
||||
def __init__(self, wallet):
|
||||
self.wallet = wallet
|
||||
|
@ -293,7 +293,7 @@ class LBRYcrdAddressQueryHandlerFactory(object):
|
|||
return "LBRYcrd Address - an address for receiving payments via LBRYcrd"
|
||||
|
||||
|
||||
class LBRYcrdAddressQueryHandler(object):
|
||||
class LBRYcrdAddressQueryHandler:
|
||||
|
||||
def __init__(self, wallet):
|
||||
self.wallet = wallet
|
||||
|
|
|
@ -16,7 +16,7 @@ from .claim_proofs import verify_proof, InvalidProofError
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Resolver(object):
|
||||
class Resolver:
|
||||
|
||||
def __init__(self, claim_trie_root, height, transaction_class, hash160_to_address, network):
|
||||
self.claim_trie_root = claim_trie_root
|
||||
|
|
|
@ -14,14 +14,14 @@ class GUID(ctypes.Structure):
|
|||
]
|
||||
|
||||
def __init__(self, uuid_):
|
||||
ctypes.Structure.__init__(self)
|
||||
super().__init__()
|
||||
self.Data1, self.Data2, self.Data3, self.Data4[0], self.Data4[1], rest = uuid_.fields
|
||||
for i in range(2, 8):
|
||||
self.Data4[i] = rest>>(8 - i - 1)*8 & 0xff
|
||||
|
||||
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/dd378457.aspx
|
||||
class FOLDERID(object):
|
||||
class FOLDERID:
|
||||
# pylint: disable=bad-whitespace
|
||||
AccountPictures = UUID('{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}')
|
||||
AdminTools = UUID('{724EF170-A42D-4FEF-9F26-B60E846FBA4F}')
|
||||
|
@ -120,7 +120,7 @@ class FOLDERID(object):
|
|||
|
||||
|
||||
# http://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
|
||||
class UserHandle(object):
|
||||
class UserHandle:
|
||||
current = wintypes.HANDLE(0)
|
||||
common = wintypes.HANDLE(-1)
|
||||
|
||||
|
|
Loading…
Reference in a new issue