diff --git a/lbrynet/blob/__init__.py b/lbrynet/blob/__init__.py index 3c5de8fa9..e69de29bb 100644 --- a/lbrynet/blob/__init__.py +++ b/lbrynet/blob/__init__.py @@ -1,4 +0,0 @@ -from .blob_file import BlobFile -from .creator import BlobFileCreator -from .writer import HashBlobWriter -from .reader import HashBlobReader diff --git a/lbrynet/blob/client/CryptStreamDownloader.py b/lbrynet/blob/client/CryptStreamDownloader.py index 985e399b7..ae14b0e6d 100644 --- a/lbrynet/blob/client/CryptStreamDownloader.py +++ b/lbrynet/blob/client/CryptStreamDownloader.py @@ -10,7 +10,6 @@ from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager from lbrynet.blob.client.CryptBlobHandler import CryptBlobHandler - log = logging.getLogger(__name__) diff --git a/lbrynet/conf.py b/lbrynet/conf.py index 72ba2b700..757aced9b 100644 --- a/lbrynet/conf.py +++ b/lbrynet/conf.py @@ -15,7 +15,7 @@ from lbrynet.androidhelpers.paths import ( ) try: - from .winpaths import get_path, FOLDERID, UserHandle + from lbrynet.winpaths import get_path, FOLDERID, UserHandle except (ImportError, ValueError, NameError): # Android platform: NameError: name 'c_wchar' is not defined pass diff --git a/lbrynet/dht/contact.py b/lbrynet/dht/contact.py index afd2b4718..99c84532b 100644 --- a/lbrynet/dht/contact.py +++ b/lbrynet/dht/contact.py @@ -1,7 +1,7 @@ import ipaddress from binascii import hexlify from functools import reduce -from . import constants +from lbrynet.dht import constants def is_valid_ipv4(address): diff --git a/lbrynet/dht/datastore.py b/lbrynet/dht/datastore.py index 2ae0f393d..12be982f8 100644 --- a/lbrynet/dht/datastore.py +++ b/lbrynet/dht/datastore.py @@ -1,5 +1,5 @@ from collections import UserDict -from . import constants +from lbrynet.dht import constants class DictDataStore(UserDict): diff --git a/lbrynet/dht/distance.py b/lbrynet/dht/distance.py index 94de80433..2c1099535 100644 --- a/lbrynet/dht/distance.py +++ b/lbrynet/dht/distance.py @@ -1,4 +1,4 @@ -from . import constants +from lbrynet.dht import constants class Distance: diff --git a/lbrynet/dht/encoding.py b/lbrynet/dht/encoding.py index f31bd119f..4eb4d0764 100644 --- a/lbrynet/dht/encoding.py +++ b/lbrynet/dht/encoding.py @@ -1,4 +1,4 @@ -from .error import DecodeError +from lbrynet.dht.error import DecodeError def bencode(data): diff --git a/lbrynet/dht/iterativefind.py b/lbrynet/dht/iterativefind.py index 765c548dc..a2be6b09b 100644 --- a/lbrynet/dht/iterativefind.py +++ b/lbrynet/dht/iterativefind.py @@ -1,8 +1,8 @@ import logging from twisted.internet import defer -from .distance import Distance -from .error import TimeoutError -from . import constants +from lbrynet.dht.distance import Distance +from lbrynet.dht.error import TimeoutError +from lbrynet.dht import constants log = logging.getLogger(__name__) diff --git a/lbrynet/dht/kbucket.py b/lbrynet/dht/kbucket.py index 7fffb4ce7..fa3f19d2e 100644 --- a/lbrynet/dht/kbucket.py +++ b/lbrynet/dht/kbucket.py @@ -1,8 +1,8 @@ import logging -from . import constants -from .distance import Distance -from .error import BucketFull +from lbrynet.dht import constants +from lbrynet.dht.distance import Distance +from lbrynet.dht.error import BucketFull log = logging.getLogger(__name__) diff --git a/lbrynet/dht/msgformat.py b/lbrynet/dht/msgformat.py index fc4381d1c..5e4c59d79 100644 --- a/lbrynet/dht/msgformat.py +++ b/lbrynet/dht/msgformat.py @@ -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 -from . import msgtypes +from lbrynet.dht import msgtypes class MessageTranslator: diff --git a/lbrynet/dht/msgtypes.py b/lbrynet/dht/msgtypes.py index 59f9440bd..907c1a8e7 100644 --- a/lbrynet/dht/msgtypes.py +++ b/lbrynet/dht/msgtypes.py @@ -8,7 +8,7 @@ # may be created by processing this file with epydoc: http://epydoc.sf.net from lbrynet.utils import generate_id -from . import constants +from lbrynet.dht import constants class Message: diff --git a/lbrynet/dht/node.py b/lbrynet/dht/node.py index 793e46b76..fc5618d05 100644 --- a/lbrynet/dht/node.py +++ b/lbrynet/dht/node.py @@ -6,14 +6,11 @@ from functools import reduce from twisted.internet import defer, error, task from lbrynet.utils import generate_id, DeferredDict -from .call_later_manager import CallLaterManager -from .error import TimeoutError -from . import constants -from . import routingtable -from . import datastore -from . import protocol -from .contact import ContactManager -from .iterativefind import iterativeFind +from lbrynet.dht.call_later_manager import CallLaterManager +from lbrynet.dht.error import TimeoutError +from lbrynet.dht import constants, routingtable, datastore, protocol +from lbrynet.dht.contact import ContactManager +from lbrynet.dht.iterativefind import iterativeFind log = logging.getLogger(__name__) diff --git a/lbrynet/dht/protocol.py b/lbrynet/dht/protocol.py index 18d55977a..6504baea3 100644 --- a/lbrynet/dht/protocol.py +++ b/lbrynet/dht/protocol.py @@ -3,12 +3,8 @@ import errno from binascii import hexlify from twisted.internet import protocol, defer -from .error import BUILTIN_EXCEPTIONS, UnknownRemoteException, TimeoutError, TransportNotConnected - -from . import constants -from . import encoding -from . import msgtypes -from . import msgformat +from lbrynet.dht import constants, encoding, msgformat, msgtypes +from lbrynet.dht.error import BUILTIN_EXCEPTIONS, UnknownRemoteException, TimeoutError, TransportNotConnected log = logging.getLogger(__name__) diff --git a/lbrynet/dht/routingtable.py b/lbrynet/dht/routingtable.py index 7417e3970..dc8ff8089 100644 --- a/lbrynet/dht/routingtable.py +++ b/lbrynet/dht/routingtable.py @@ -6,14 +6,13 @@ # may be created by processing this file with epydoc: http://epydoc.sf.net import random -from binascii import unhexlify - -from twisted.internet import defer -from . import constants -from . import kbucket -from .error import TimeoutError -from .distance import Distance import logging +from binascii import unhexlify +from twisted.internet import defer + +from lbrynet.dht import constants, kbucket +from lbrynet.dht.error import TimeoutError +from lbrynet.dht.distance import Distance log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/Component.py b/lbrynet/extras/daemon/Component.py index 03f03ddf5..8de53a6ae 100644 --- a/lbrynet/extras/daemon/Component.py +++ b/lbrynet/extras/daemon/Component.py @@ -1,7 +1,7 @@ import logging from twisted.internet import defer from twisted._threads import AlreadyQuit -from .ComponentManager import ComponentManager +from lbrynet.extras.daemon.ComponentManager import ComponentManager log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/ComponentManager.py b/lbrynet/extras/daemon/ComponentManager.py index 3ccf5889b..9af07fd8d 100644 --- a/lbrynet/extras/daemon/ComponentManager.py +++ b/lbrynet/extras/daemon/ComponentManager.py @@ -1,8 +1,8 @@ import logging from twisted.internet import defer from lbrynet.p2p.Error import ComponentStartConditionNotMet -from .PeerManager import PeerManager -from .PeerFinder import DHTPeerFinder +from lbrynet.extras.daemon.PeerManager import PeerManager +from lbrynet.extras.daemon.PeerFinder import DHTPeerFinder log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/Components.py b/lbrynet/extras/daemon/Components.py index cbcf06ed5..9751adb78 100644 --- a/lbrynet/extras/daemon/Components.py +++ b/lbrynet/extras/daemon/Components.py @@ -8,30 +8,33 @@ import binascii from hashlib import sha256 from types import SimpleNamespace from twisted.internet import defer, threads, reactor, error, task -import lbrynet.schema + from aioupnp import __version__ as aioupnp_version from aioupnp.upnp import UPnP from aioupnp.fault import UPnPError + +import lbrynet.schema from lbrynet import conf + +from lbrynet.blob.EncryptedFileManager import EncryptedFileManager +from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaverFactory +from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier +from lbrynet.dht.node import Node +from lbrynet.extras.daemon.Component import Component +from lbrynet.extras.daemon.ExchangeRateManager import ExchangeRateManager +from lbrynet.extras.daemon.storage import SQLiteStorage +from lbrynet.extras.daemon.HashAnnouncer import DHTHashAnnouncer +from lbrynet.extras.reflector.server.server import ReflectorServerFactory +from lbrynet.extras.wallet import LbryWalletManager +from lbrynet.extras.wallet import Network from lbrynet.utils import DeferredDict, generate_id from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.RateLimiter import RateLimiter from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier, EncryptedFileStreamType -from lbrynet.extras.wallet import LbryWalletManager -from lbrynet.extras.wallet import Network from lbrynet.p2p.server.BlobRequestHandler import BlobRequestHandlerFactory from lbrynet.p2p.server.ServerProtocol import ServerProtocolFactory -from .Component import Component -from .ExchangeRateManager import ExchangeRateManager -from .storage import SQLiteStorage -from .HashAnnouncer import DHTHashAnnouncer -from lbrynet.dht.node import Node -from lbrynet.blob.EncryptedFileManager import EncryptedFileManager -from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaverFactory -from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier -from lbrynet.extras.reflector import ServerFactory as reflector_server_factory log = logging.getLogger(__name__) @@ -649,7 +652,7 @@ class ReflectorComponent(Component): log.info("Starting reflector server") blob_manager = self.component_manager.get_component(BLOB_COMPONENT) file_manager = self.component_manager.get_component(FILE_MANAGER_COMPONENT) - reflector_factory = reflector_server_factory(self.component_manager.peer_manager, blob_manager, file_manager) + reflector_factory = ReflectorServerFactory(self.component_manager.peer_manager, blob_manager, file_manager) try: self.reflector_server = yield reactor.listenTCP(self.reflector_server_port, reflector_factory) log.info('Started reflector on port %s', self.reflector_server_port) diff --git a/lbrynet/extras/daemon/Daemon.py b/lbrynet/extras/daemon/Daemon.py index ddb771bd0..cdd64458e 100644 --- a/lbrynet/extras/daemon/Daemon.py +++ b/lbrynet/extras/daemon/Daemon.py @@ -17,7 +17,26 @@ from twisted.python.failure import Failure from torba.client.baseaccount import SingleKey, HierarchicalDeterministic from lbrynet import conf, utils, __version__ +from lbrynet.dht.error import TimeoutError from lbrynet.extras import system_info +from lbrynet.extras.reflector import reupload +from lbrynet.extras.daemon.Components import d2f, f2d +from lbrynet.extras.daemon.Components import WALLET_COMPONENT, DATABASE_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT +from lbrynet.extras.daemon.Components import FILE_MANAGER_COMPONENT, RATE_LIMITER_COMPONENT +from lbrynet.extras.daemon.Components import EXCHANGE_RATE_MANAGER_COMPONENT, PAYMENT_RATE_COMPONENT, UPNP_COMPONENT +from lbrynet.extras.daemon.ComponentManager import RequiredCondition +from lbrynet.extras.daemon.Downloader import GetStream +from lbrynet.extras.daemon.Publisher import Publisher +from lbrynet.extras.daemon.auth.server import AuthJSONRPCServer +from lbrynet.extras.wallet import LbryWalletManager +from lbrynet.extras.wallet.account import Account as LBCAccount +from lbrynet.extras.wallet.dewies import dewies_to_lbc, lbc_to_dewies +from lbrynet.p2p.StreamDescriptor import download_sd_blob +from lbrynet.p2p.Error import InsufficientFundsError, UnknownNameError, DownloadDataTimeout, DownloadSDTimeout +from lbrynet.p2p.Error import NullFundsError, NegativeFundsError, ResolveError +from lbrynet.p2p.Peer import Peer +from lbrynet.p2p.SinglePeerDownloader import SinglePeerDownloader +from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader from lbrynet.schema.claim import ClaimDict from lbrynet.schema.uri import parse_lbry_uri from lbrynet.schema.error import URIParseError, DecodeError @@ -25,28 +44,6 @@ from lbrynet.schema.validator import validate_claim_id from lbrynet.schema.address import decode_address from lbrynet.schema.decode import smart_decode -from lbrynet.extras.reflector import reupload -from .Components import d2f, f2d -from .Components import WALLET_COMPONENT, DATABASE_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT -from .Components import FILE_MANAGER_COMPONENT, RATE_LIMITER_COMPONENT -from .Components import EXCHANGE_RATE_MANAGER_COMPONENT, PAYMENT_RATE_COMPONENT, UPNP_COMPONENT -from .ComponentManager import RequiredCondition -from .Downloader import GetStream -from .Publisher import Publisher -from .auth.server import AuthJSONRPCServer -from lbrynet.p2p.StreamDescriptor import download_sd_blob -from lbrynet.p2p.Error import InsufficientFundsError, UnknownNameError -from lbrynet.p2p.Error import DownloadDataTimeout, DownloadSDTimeout -from lbrynet.p2p.Error import NullFundsError, NegativeFundsError -from lbrynet.p2p.Error import ResolveError -from lbrynet.dht.error import TimeoutError -from lbrynet.p2p.Peer import Peer -from lbrynet.p2p.SinglePeerDownloader import SinglePeerDownloader -from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader -from lbrynet.extras.wallet import LbryWalletManager -from lbrynet.extras.wallet.account import Account as LBCAccount -from lbrynet.extras.wallet.dewies import dewies_to_lbc, lbc_to_dewies - log = logging.getLogger(__name__) requires = AuthJSONRPCServer.requires diff --git a/lbrynet/extras/daemon/DaemonConsole.py b/lbrynet/extras/daemon/DaemonConsole.py index c7e82c6ac..d3a1c1d67 100644 --- a/lbrynet/extras/daemon/DaemonConsole.py +++ b/lbrynet/extras/daemon/DaemonConsole.py @@ -6,11 +6,10 @@ import logging.handlers from twisted.internet import defer, reactor, threads from aiohttp import client_exceptions +from lbrynet import utils, conf, log_support from lbrynet.extras.daemon import analytics -from lbrynet import utils, conf -from lbrynet import log_support -from .auth.client import LBRYAPIClient -from .Daemon import Daemon +from lbrynet.extras.daemon.auth.client import LBRYAPIClient +from lbrynet.extras.daemon.Daemon import Daemon log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/DaemonControl.py b/lbrynet/extras/daemon/DaemonControl.py index bdaa71dc8..0ad0158fc 100644 --- a/lbrynet/extras/daemon/DaemonControl.py +++ b/lbrynet/extras/daemon/DaemonControl.py @@ -14,7 +14,7 @@ import logging.handlers from twisted.internet import reactor from lbrynet import utils, conf, log_support from lbrynet.extras import system_info -from .Daemon import Daemon +from lbrynet.extras.daemon.Daemon import Daemon log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/Downloader.py b/lbrynet/extras/daemon/Downloader.py index 5c73c49e7..f4badd0ad 100644 --- a/lbrynet/extras/daemon/Downloader.py +++ b/lbrynet/extras/daemon/Downloader.py @@ -3,7 +3,6 @@ import os from twisted.internet import defer from twisted.internet.task import LoopingCall -from .Components import f2d from lbrynet import conf from lbrynet.schema.fee import Fee @@ -14,6 +13,7 @@ from lbrynet.p2p.StreamDescriptor import download_sd_blob from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory from torba.client.constants import COIN from lbrynet.extras.wallet.dewies import dewies_to_lbc +from lbrynet.extras.daemon.Components import f2d INITIALIZING_CODE = 'initializing' DOWNLOAD_METADATA_CODE = 'downloading_metadata' diff --git a/lbrynet/extras/daemon/__init__.py b/lbrynet/extras/daemon/__init__.py index 7d3f2be07..9fb57d0d9 100644 --- a/lbrynet/extras/daemon/__init__.py +++ b/lbrynet/extras/daemon/__init__.py @@ -1 +1 @@ -from . import Components # register Component classes +from lbrynet.extras.daemon import Components # register Component classes diff --git a/lbrynet/extras/daemon/auth/auth.py b/lbrynet/extras/daemon/auth/auth.py index 5fb5cd2e7..8e350589a 100644 --- a/lbrynet/extras/daemon/auth/auth.py +++ b/lbrynet/extras/daemon/auth/auth.py @@ -3,7 +3,7 @@ from zope.interface import implementer from twisted.cred import portal, checkers, credentials, error as cred_error from twisted.internet import defer from twisted.web import resource -from .keyring import Keyring +from lbrynet.extras.daemon.auth.keyring import Keyring log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/auth/client.py b/lbrynet/extras/daemon/auth/client.py index cb9c657f9..50b0def8b 100644 --- a/lbrynet/extras/daemon/auth/client.py +++ b/lbrynet/extras/daemon/auth/client.py @@ -4,7 +4,7 @@ import logging from urllib.parse import urlparse from lbrynet import conf -from .keyring import Keyring, APIKey +from lbrynet.extras.daemon.auth.keyring import Keyring, APIKey log = logging.getLogger(__name__) USER_AGENT = "AuthServiceProxy/0.1" diff --git a/lbrynet/extras/daemon/auth/factory.py b/lbrynet/extras/daemon/auth/factory.py index 549b9bd68..163d49fe0 100644 --- a/lbrynet/extras/daemon/auth/factory.py +++ b/lbrynet/extras/daemon/auth/factory.py @@ -4,8 +4,8 @@ from twisted.web import server, guard, resource from twisted.cred import portal from lbrynet import conf -from .auth import PasswordChecker, HttpPasswordRealm -from ..auth.keyring import Keyring +from lbrynet.extras.daemon.auth.auth import PasswordChecker, HttpPasswordRealm +from lbrynet.extras.daemon.auth.keyring import Keyring log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/auth/keyring.py b/lbrynet/extras/daemon/auth/keyring.py index 91d9290a1..eb4f7011a 100644 --- a/lbrynet/extras/daemon/auth/keyring.py +++ b/lbrynet/extras/daemon/auth/keyring.py @@ -3,6 +3,7 @@ import datetime import hmac import hashlib import base58 +import logging from OpenSSL.crypto import FILETYPE_PEM from ssl import create_default_context, SSLContext from cryptography.hazmat.backends import default_backend @@ -12,7 +13,7 @@ from cryptography.x509.name import NameOID, NameAttribute from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives import serialization from twisted.internet import ssl -import logging + from lbrynet import conf log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/auth/server.py b/lbrynet/extras/daemon/auth/server.py index 93d0e8b26..82f814cf8 100644 --- a/lbrynet/extras/daemon/auth/server.py +++ b/lbrynet/extras/daemon/auth/server.py @@ -4,7 +4,6 @@ from six.moves.urllib import parse as urlparse import json import inspect import signal - from functools import wraps from twisted.web import server from twisted.internet import defer @@ -13,16 +12,18 @@ from twisted.python.failure import Failure from twisted.internet.error import ConnectionDone, ConnectionLost from txjsonrpc import jsonrpclib from traceback import format_exc + from lbrynet import conf, utils from lbrynet.extras.daemon import analytics from lbrynet.p2p.Error import InvalidAuthenticationToken from lbrynet.p2p.Error import ComponentsNotStarted, ComponentStartConditionNotMet from lbrynet.extras.looping_call_manager import LoopingCallManager from lbrynet.extras.daemon.ComponentManager import ComponentManager -from .keyring import APIKey, Keyring -from .undecorated import undecorated -from .factory import AuthJSONRPCResource +from lbrynet.extras.daemon.auth.keyring import APIKey, Keyring +from lbrynet.extras.daemon.auth.undecorated import undecorated +from lbrynet.extras.daemon.auth.factory import AuthJSONRPCResource from lbrynet.extras.daemon.json_response_encoder import JSONResponseEncoder + log = logging.getLogger(__name__) EMPTY_PARAMS = [{}] diff --git a/lbrynet/extras/daemon/migrator/migrate5to6.py b/lbrynet/extras/daemon/migrator/migrate5to6.py index 017aa965f..d8dcacdb5 100644 --- a/lbrynet/extras/daemon/migrator/migrate5to6.py +++ b/lbrynet/extras/daemon/migrator/migrate5to6.py @@ -2,8 +2,8 @@ import sqlite3 import os import json import logging -from lbrynet.schema.decode import smart_decode from lbrynet import conf +from lbrynet.schema.decode import smart_decode log = logging.getLogger(__name__) diff --git a/lbrynet/extras/daemon/storage.py b/lbrynet/extras/daemon/storage.py index 724aabeef..30c2d9330 100644 --- a/lbrynet/extras/daemon/storage.py +++ b/lbrynet/extras/daemon/storage.py @@ -6,12 +6,13 @@ from binascii import hexlify, unhexlify from decimal import Decimal from twisted.internet import defer, task, threads from twisted.enterprise import adbapi +from torba.client.constants import COIN + from lbrynet import conf from lbrynet.schema.claim import ClaimDict from lbrynet.schema.decode import smart_decode from lbrynet.blob.CryptBlob import CryptBlobInfo from lbrynet.dht.constants import dataExpireTimeout -from torba.client.constants import COIN log = logging.getLogger(__name__) diff --git a/lbrynet/extras/reflector/__init__.py b/lbrynet/extras/reflector/__init__.py index d05ef4820..56f9bfdf6 100644 --- a/lbrynet/extras/reflector/__init__.py +++ b/lbrynet/extras/reflector/__init__.py @@ -63,6 +63,3 @@ If the transfer was not successful (False), the blob is re-added to the needed_b Blob requests continue for each of the blobs the client has queued to send, when completed the client disconnects. """ -from .server.server import ReflectorServerFactory as ServerFactory -from .client.client import EncryptedFileReflectorClientFactory as ClientFactory -from .client.blob import BlobReflectorClientFactory as BlobClientFactory diff --git a/lbrynet/extras/reflector/reupload.py b/lbrynet/extras/reflector/reupload.py index a2b1548e3..1a6567d27 100644 --- a/lbrynet/extras/reflector/reupload.py +++ b/lbrynet/extras/reflector/reupload.py @@ -2,7 +2,8 @@ import random from twisted.internet import reactor, defer from lbrynet import conf -from . import ClientFactory, BlobClientFactory +from lbrynet.extras.reflector.client.client import EncryptedFileReflectorClientFactory +from lbrynet.extras.reflector.client.blob import BlobReflectorClientFactory def _is_ip(host): @@ -26,7 +27,7 @@ def resolve(host): @defer.inlineCallbacks def _reflect_stream(blob_manager, stream_hash, sd_hash, reflector_server): reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = ClientFactory(blob_manager, stream_hash, sd_hash) + factory = EncryptedFileReflectorClientFactory(blob_manager, stream_hash, sd_hash) ip = yield resolve(reflector_address) yield reactor.connectTCP(ip, reflector_port, factory) result = yield factory.finished_deferred @@ -40,7 +41,7 @@ def _reflect_file(lbry_file, reflector_server): @defer.inlineCallbacks def _reflect_blobs(blob_manager, blob_hashes, reflector_server): reflector_address, reflector_port = reflector_server[0], reflector_server[1] - factory = BlobClientFactory(blob_manager, blob_hashes) + factory = BlobReflectorClientFactory(blob_manager, blob_hashes) ip = yield resolve(reflector_address) yield reactor.connectTCP(ip, reflector_port, factory) result = yield factory.finished_deferred diff --git a/lbrynet/extras/system_info.py b/lbrynet/extras/system_info.py index d3552d4f7..63fa3b065 100644 --- a/lbrynet/extras/system_info.py +++ b/lbrynet/extras/system_info.py @@ -1,9 +1,9 @@ import platform import os +import logging.handlers from lbrynet.schema import __version__ as schema_version from lbrynet import build_type, __version__ as lbrynet_version -import logging.handlers log = logging.getLogger(__name__) diff --git a/lbrynet/extras/wallet/__init__.py b/lbrynet/extras/wallet/__init__.py index 80205e427..b2ee7b8a5 100644 --- a/lbrynet/extras/wallet/__init__.py +++ b/lbrynet/extras/wallet/__init__.py @@ -6,6 +6,6 @@ __node_url__ = ( ) __spvserver__ = 'lbrynet.extras.wallet.server.coin.LBCRegTest' -from .ledger import MainNetLedger, RegTestLedger -from .manager import LbryWalletManager -from .network import Network +from lbrynet.extras.wallet.ledger import MainNetLedger, RegTestLedger +from lbrynet.extras.wallet.manager import LbryWalletManager +from lbrynet.extras.wallet.network import Network diff --git a/lbrynet/extras/wallet/ledger.py b/lbrynet/extras/wallet/ledger.py index dcddad4f7..7245ae8c4 100644 --- a/lbrynet/extras/wallet/ledger.py +++ b/lbrynet/extras/wallet/ledger.py @@ -2,17 +2,16 @@ import asyncio import logging from binascii import unhexlify -from lbrynet.extras.wallet.dewies import dewies_to_lbc +from torba.client.baseledger import BaseLedger from lbrynet.schema.error import URIParseError from lbrynet.schema.uri import parse_lbry_uri -from torba.client.baseledger import BaseLedger - -from .resolve import Resolver -from .account import Account -from .network import Network -from .database import WalletDatabase -from .transaction import Transaction -from .header import Headers, UnvalidatedHeaders +from lbrynet.extras.wallet.dewies import dewies_to_lbc +from lbrynet.extras.wallet.resolve import Resolver +from lbrynet.extras.wallet.account import Account +from lbrynet.extras.wallet.network import Network +from lbrynet.extras.wallet.database import WalletDatabase +from lbrynet.extras.wallet.transaction import Transaction +from lbrynet.extras.wallet.header import Headers, UnvalidatedHeaders log = logging.getLogger(__name__) diff --git a/lbrynet/extras/wallet/manager.py b/lbrynet/extras/wallet/manager.py index 8e11cc1bd..692651e43 100644 --- a/lbrynet/extras/wallet/manager.py +++ b/lbrynet/extras/wallet/manager.py @@ -14,11 +14,11 @@ from torba.client.basemanager import BaseWalletManager from lbrynet.schema.claim import ClaimDict -from .ledger import MainNetLedger -from .account import BaseAccount, generate_certificate -from .transaction import Transaction -from .database import WalletDatabase -from .dewies import dewies_to_lbc +from lbrynet.extras.wallet.ledger import MainNetLedger +from lbrynet.extras.wallet.account import BaseAccount, generate_certificate +from lbrynet.extras.wallet.transaction import Transaction +from lbrynet.extras.wallet.database import WalletDatabase +from lbrynet.extras.wallet.dewies import dewies_to_lbc log = logging.getLogger(__name__) diff --git a/lbrynet/extras/wallet/resolve.py b/lbrynet/extras/wallet/resolve.py index b3195c394..6f5fef78f 100644 --- a/lbrynet/extras/wallet/resolve.py +++ b/lbrynet/extras/wallet/resolve.py @@ -9,8 +9,7 @@ from lbrynet.schema.claim import ClaimDict from lbrynet.schema.decode import smart_decode from lbrynet.schema.error import DecodeError from lbrynet.schema.uri import parse_lbry_uri - -from .claim_proofs import verify_proof, InvalidProofError +from lbrynet.extras.wallet.claim_proofs import verify_proof, InvalidProofError log = logging.getLogger(__name__) diff --git a/lbrynet/extras/wallet/server/block_processor.py b/lbrynet/extras/wallet/server/block_processor.py index 9937f4298..eae699d67 100644 --- a/lbrynet/extras/wallet/server/block_processor.py +++ b/lbrynet/extras/wallet/server/block_processor.py @@ -9,7 +9,7 @@ from lbrynet.schema.proto.claim_pb2 import Claim from lbrynet.schema.uri import parse_lbry_uri from lbrynet.schema.decode import smart_decode -from .model import NameClaim, ClaimInfo, ClaimUpdate, ClaimSupport +from lbrynet.extras.wallet.server.model import NameClaim, ClaimInfo, ClaimUpdate, ClaimSupport class LBRYBlockProcessor(BlockProcessor): diff --git a/lbrynet/extras/wallet/server/coin.py b/lbrynet/extras/wallet/server/coin.py index 7d991565a..de5d8ef1e 100644 --- a/lbrynet/extras/wallet/server/coin.py +++ b/lbrynet/extras/wallet/server/coin.py @@ -6,7 +6,7 @@ from torba.server.hash import hash_to_hex_str, HASHX_LEN from hashlib import sha256 from torba.server.coins import Coin, CoinError -from .opcodes import decode_claim_script, opcodes as lbry_opcodes +from lbrynet.extras.wallet.server.opcodes import decode_claim_script, opcodes as lbry_opcodes class LBC(Coin): diff --git a/lbrynet/extras/wallet/server/db.py b/lbrynet/extras/wallet/server/db.py index 1bcb891bc..de2ad15b2 100644 --- a/lbrynet/extras/wallet/server/db.py +++ b/lbrynet/extras/wallet/server/db.py @@ -6,7 +6,7 @@ from torba.server.hash import hash_to_hex_str from torba.server.db import DB -from .model import ClaimInfo +from lbrynet.extras.wallet.server.model import ClaimInfo class LBRYDB(DB): diff --git a/lbrynet/extras/wallet/server/opcodes.py b/lbrynet/extras/wallet/server/opcodes.py index 2b697a064..8e17f5a25 100644 --- a/lbrynet/extras/wallet/server/opcodes.py +++ b/lbrynet/extras/wallet/server/opcodes.py @@ -1,6 +1,6 @@ import struct from torba.server.enum import Enumeration -from .model import NameClaim, ClaimSupport, ClaimUpdate +from lbrynet.extras.wallet.server.model import NameClaim, ClaimSupport, ClaimUpdate # TODO: Take this to lbryschema (it's also on lbryum and lbryum-server) diff --git a/lbrynet/extras/wallet/server/session.py b/lbrynet/extras/wallet/server/session.py index 037e23817..50313da7e 100644 --- a/lbrynet/extras/wallet/server/session.py +++ b/lbrynet/extras/wallet/server/session.py @@ -8,8 +8,8 @@ from torba.server import util from lbrynet.schema.uri import parse_lbry_uri from lbrynet.schema.error import URIParseError -from .block_processor import LBRYBlockProcessor -from .db import LBRYDB +from lbrynet.extras.wallet.server.block_processor import LBRYBlockProcessor +from lbrynet.extras.wallet.server.db import LBRYDB class LBRYElectrumX(ElectrumX): diff --git a/lbrynet/extras/wallet/server/tx.py b/lbrynet/extras/wallet/server/tx.py index 4d24c4088..eba24d751 100644 --- a/lbrynet/extras/wallet/server/tx.py +++ b/lbrynet/extras/wallet/server/tx.py @@ -1,6 +1,6 @@ from torba.server.tx import Deserializer -from .opcodes import decode_claim_script -from .model import TxClaimOutput, LBRYTx +from lbrynet.extras.wallet.server.opcodes import decode_claim_script +from lbrynet.extras.wallet.server.model import TxClaimOutput, LBRYTx class LBRYDeserializer(Deserializer): diff --git a/lbrynet/extras/wallet/transaction.py b/lbrynet/extras/wallet/transaction.py index 55856d7cf..fea2fff52 100644 --- a/lbrynet/extras/wallet/transaction.py +++ b/lbrynet/extras/wallet/transaction.py @@ -2,13 +2,12 @@ import struct from binascii import hexlify, unhexlify from typing import List, Iterable, Optional -from lbrynet.schema.decode import smart_decode -from .account import Account from torba.client.basetransaction import BaseTransaction, BaseInput, BaseOutput from torba.client.hash import hash160 - +from lbrynet.schema.decode import smart_decode from lbrynet.schema.claim import ClaimDict -from .script import InputScript, OutputScript +from lbrynet.extras.wallet.account import Account +from lbrynet.extras.wallet.script import InputScript, OutputScript class Input(BaseInput): diff --git a/lbrynet/p2p/BlobAvailability.py b/lbrynet/p2p/BlobAvailability.py index 36fb92a27..0ddb7072e 100644 --- a/lbrynet/p2p/BlobAvailability.py +++ b/lbrynet/p2p/BlobAvailability.py @@ -1,10 +1,9 @@ import logging import random import time - +from decimal import Decimal from twisted.internet import defer from twisted.internet.task import LoopingCall -from decimal import Decimal log = logging.getLogger(__name__) diff --git a/lbrynet/p2p/HTTPBlobDownloader.py b/lbrynet/p2p/HTTPBlobDownloader.py index 62e685f48..28e6e2a4b 100644 --- a/lbrynet/p2p/HTTPBlobDownloader.py +++ b/lbrynet/p2p/HTTPBlobDownloader.py @@ -1,9 +1,10 @@ -from random import choice import logging +import treq +from random import choice from twisted.internet import defer, task from twisted.internet.error import ConnectingCancelledError from twisted.web._newclient import ResponseNeverReceived -import treq + from lbrynet.utils import DeferredDict from lbrynet.p2p.Error import DownloadCanceledError diff --git a/lbrynet/p2p/PaymentRateManager.py b/lbrynet/p2p/PaymentRateManager.py index 372204365..7eb8b142c 100644 --- a/lbrynet/p2p/PaymentRateManager.py +++ b/lbrynet/p2p/PaymentRateManager.py @@ -1,6 +1,6 @@ -from lbrynet.p2p.Strategy import get_default_strategy, OnlyFreeStrategy -from lbrynet import conf from decimal import Decimal +from lbrynet import conf +from lbrynet.p2p.Strategy import get_default_strategy, OnlyFreeStrategy class BasePaymentRateManager: diff --git a/lbrynet/p2p/SinglePeerDownloader.py b/lbrynet/p2p/SinglePeerDownloader.py index 7936caa85..682939427 100644 --- a/lbrynet/p2p/SinglePeerDownloader.py +++ b/lbrynet/p2p/SinglePeerDownloader.py @@ -4,7 +4,7 @@ import tempfile from twisted.internet import defer, threads, reactor -from lbrynet.blob import BlobFile +from lbrynet.blob.blob_file import BlobFile from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.RateLimiter import DummyRateLimiter from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager diff --git a/lbrynet/p2p/StreamDescriptor.py b/lbrynet/p2p/StreamDescriptor.py index 534d02db6..9ef1048d3 100644 --- a/lbrynet/p2p/StreamDescriptor.py +++ b/lbrynet/p2p/StreamDescriptor.py @@ -1,10 +1,10 @@ -from binascii import unhexlify import string -from collections import defaultdict import json import logging - +from collections import defaultdict +from binascii import unhexlify from twisted.internet import threads, defer + from lbrynet.cryptoutils import get_lbry_hash_obj from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader from lbrynet.p2p.Error import UnknownStreamTypeError, InvalidStreamDescriptorError diff --git a/lbrynet/schema/decode.py b/lbrynet/schema/decode.py index 95aa18a5b..e5be724e4 100644 --- a/lbrynet/schema/decode.py +++ b/lbrynet/schema/decode.py @@ -1,13 +1,12 @@ import json import binascii - +from google.protobuf import json_format # pylint: disable=no-name-in-module import six from lbrynet.schema.error import DecodeError, InvalidAddress from lbrynet.schema.legacy.migrate import migrate as schema_migrator from lbrynet.schema.claim import ClaimDict -from google.protobuf import json_format # pylint: disable=no-name-in-module def migrate_json_claim_value(decoded_json): diff --git a/tests/functional/test_reflector.py b/tests/functional/test_reflector.py index 5b9cfc116..6c2ff7285 100644 --- a/tests/functional/test_reflector.py +++ b/tests/functional/test_reflector.py @@ -4,7 +4,9 @@ from binascii import hexlify from twisted.internet import defer, error from twisted.trial import unittest from lbrynet.p2p.StreamDescriptor import get_sd_info -from lbrynet.extras import reflector +from lbrynet.extras.reflector.server.server import ReflectorServerFactory +from lbrynet.extras.reflector.client.client import EncryptedFileReflectorClientFactory +from lbrynet.extras.reflector.client.blob import BlobReflectorClientFactory from lbrynet.extras.daemon.PeerManager import PeerManager from lbrynet.p2p import BlobManager from lbrynet.p2p import StreamDescriptor @@ -96,7 +98,7 @@ class TestReflector(unittest.TestCase): return d def start_server(): - server_factory = reflector.ServerFactory(peer_manager, self.server_blob_manager, + server_factory = ReflectorServerFactory(peer_manager, self.server_blob_manager, self.server_lbry_file_manager) from twisted.internet import reactor port = 8943 @@ -180,7 +182,7 @@ class TestReflector(unittest.TestCase): return d def send_to_server(): - factory = reflector.ClientFactory(self.client_blob_manager, self.stream_hash, self.sd_hash) + factory = EncryptedFileReflectorClientFactory(self.client_blob_manager, self.stream_hash, self.sd_hash) from twisted.internet import reactor reactor.connectTCP('localhost', self.port, factory) @@ -209,7 +211,7 @@ class TestReflector(unittest.TestCase): return d def send_to_server(blob_hashes_to_send): - factory = reflector.BlobClientFactory( + factory = BlobReflectorClientFactory( self.client_blob_manager, blob_hashes_to_send ) @@ -248,7 +250,7 @@ class TestReflector(unittest.TestCase): return d def send_to_server(blob_hashes_to_send): - factory = reflector.BlobClientFactory( + factory = BlobReflectorClientFactory( self.client_blob_manager, blob_hashes_to_send ) @@ -302,7 +304,7 @@ class TestReflector(unittest.TestCase): return d def send_to_server_as_blobs(blob_hashes_to_send): - factory = reflector.BlobClientFactory( + factory = BlobReflectorClientFactory( self.client_blob_manager, blob_hashes_to_send ) @@ -313,7 +315,7 @@ class TestReflector(unittest.TestCase): return factory.finished_deferred def send_to_server_as_stream(result): - factory = reflector.ClientFactory(self.client_blob_manager, self.stream_hash, self.sd_hash) + factory = EncryptedFileReflectorClientFactory(self.client_blob_manager, self.stream_hash, self.sd_hash) from twisted.internet import reactor reactor.connectTCP('localhost', self.port, factory) diff --git a/tests/unit/core/test_HTTPBlobDownloader.py b/tests/unit/core/test_HTTPBlobDownloader.py index 5112e38aa..3916e6ba8 100644 --- a/tests/unit/core/test_HTTPBlobDownloader.py +++ b/tests/unit/core/test_HTTPBlobDownloader.py @@ -3,7 +3,7 @@ from mock import MagicMock from twisted.trial import unittest from twisted.internet import defer -from lbrynet.blob import BlobFile +from lbrynet.blob.blob_file import BlobFile from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir diff --git a/tests/unit/core/test_HashBlob.py b/tests/unit/core/test_HashBlob.py index d7c5003c6..da8b3f5bc 100644 --- a/tests/unit/core/test_HashBlob.py +++ b/tests/unit/core/test_HashBlob.py @@ -1,4 +1,4 @@ -from lbrynet.blob import BlobFile +from lbrynet.blob.blob_file import BlobFile from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir, random_lbry_hash