move files

This commit is contained in:
Jack Robison 2018-11-07 15:15:05 -05:00
parent 488b976734
commit a6b643bb34
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2
77 changed files with 131 additions and 154 deletions

View file

@ -2,8 +2,8 @@
Utilities for turning plain files into LBRY Files. Utilities for turning plain files into LBRY Files.
""" """
import logging
import os import os
import logging
from binascii import hexlify from binascii import hexlify
from twisted.internet import defer from twisted.internet import defer

View file

@ -5,10 +5,10 @@ import logging
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from twisted.internet import defer from twisted.internet import defer
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager
from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader
from lbrynet.p2p.utils import short_hash from lbrynet.utils import short_hash
from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaver from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaver
from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileDownloader from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileDownloader
from lbrynet.blob.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.blob.EncryptedFileStatusReport import EncryptedFileStatusReport

View file

@ -7,14 +7,14 @@ from binascii import hexlify, unhexlify
from twisted.internet import defer, task, reactor from twisted.internet import defer, task, reactor
from twisted.python.failure import Failure from twisted.python.failure import Failure
from lbrynet import conf
from lbrynet.extras.reflector.reupload import reflect_file from lbrynet.extras.reflector.reupload import reflect_file
from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader
from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory
from lbrynet.p2p.StreamDescriptor import EncryptedFileStreamType, get_sd_info from lbrynet.p2p.StreamDescriptor import EncryptedFileStreamType, get_sd_info
from lbrynet.blob.client.CryptStreamDownloader import AlreadyStoppedError from lbrynet.blob.client.CryptStreamDownloader import AlreadyStoppedError
from lbrynet.blob.client.CryptStreamDownloader import CurrentlyStoppingError from lbrynet.blob.client.CryptStreamDownloader import CurrentlyStoppingError
from lbrynet.p2p.utils import safe_start_looping_call, safe_stop_looping_call from lbrynet.utils import safe_start_looping_call, safe_stop_looping_call
from lbrynet.extras.daemon import conf
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,10 +1,10 @@
import logging
import os import os
import logging
from twisted.internet import defer, threads from twisted.internet import defer, threads
from twisted.web.client import FileBodyProducer from twisted.web.client import FileBodyProducer
from twisted.python.failure import Failure from twisted.python.failure import Failure
from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError, InvalidBlobHashError from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError, InvalidBlobHashError
from lbrynet.p2p.utils import is_valid_blobhash from lbrynet.utils import is_valid_blobhash
from lbrynet.blob.writer import HashBlobWriter from lbrynet.blob.writer import HashBlobWriter
from lbrynet.blob.reader import HashBlobReader from lbrynet.blob.reader import HashBlobReader

View file

@ -1,12 +1,14 @@
from binascii import unhexlify
import logging import logging
from binascii import unhexlify
from twisted.internet import defer
from twisted.python.failure import Failure
from lbrynet.p2p.client.BlobRequester import BlobRequester from lbrynet.p2p.client.BlobRequester import BlobRequester
from lbrynet.p2p.client.ConnectionManager import ConnectionManager from lbrynet.p2p.client.ConnectionManager import ConnectionManager
from lbrynet.p2p.client.DownloadManager import DownloadManager from lbrynet.p2p.client.DownloadManager import DownloadManager
from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager
from lbrynet.blob.client.CryptBlobHandler import CryptBlobHandler from lbrynet.blob.client.CryptBlobHandler import CryptBlobHandler
from twisted.internet import defer
from twisted.python.failure import Failure
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -2,13 +2,13 @@ import os
import logging import logging
import traceback import traceback
from binascii import hexlify, unhexlify from binascii import hexlify, unhexlify
from twisted.internet import defer, threads
from lbrynet.p2p.StreamDescriptor import save_sd_info from lbrynet.p2p.StreamDescriptor import save_sd_info
from lbrynet.blob.client.CryptStreamDownloader import CryptStreamDownloader from lbrynet.blob.client.CryptStreamDownloader import CryptStreamDownloader
from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager from lbrynet.p2p.client.StreamProgressManager import FullStreamProgressManager
from lbrynet.p2p.Error import FileOpenError from lbrynet.p2p.Error import FileOpenError
from lbrynet.blob.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler from lbrynet.blob.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler
from twisted.internet import defer, threads
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -3,7 +3,7 @@ import logging
from io import BytesIO from io import BytesIO
from twisted.internet import defer from twisted.internet import defer
from twisted.web.client import FileBodyProducer from twisted.web.client import FileBodyProducer
from lbrynet.p2p.cryptoutils import get_lbry_hash_obj from lbrynet.cryptoutils import get_lbry_hash_obj
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -2,7 +2,7 @@ import logging
from io import BytesIO from io import BytesIO
from twisted.python.failure import Failure from twisted.python.failure import Failure
from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError
from lbrynet.p2p.cryptoutils import get_lbry_hash_obj from lbrynet.cryptoutils import get_lbry_hash_obj
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -7,7 +7,7 @@ import sys
import yaml import yaml
import envparse import envparse
from appdirs import user_data_dir, user_config_dir from appdirs import user_data_dir, user_config_dir
from lbrynet.p2p import utils from lbrynet import utils
from lbrynet.p2p.Error import InvalidCurrencyError, NoSuchDirectoryError from lbrynet.p2p.Error import InvalidCurrencyError, NoSuchDirectoryError
from lbrynet.androidhelpers.paths import ( from lbrynet.androidhelpers.paths import (
android_internal_storage_dir, android_internal_storage_dir,

View file

@ -1,7 +1,7 @@
import ipaddress import ipaddress
from binascii import hexlify from binascii import hexlify
from functools import reduce from functools import reduce
from lbrynet.dht import constants from . import constants
def is_valid_ipv4(address): def is_valid_ipv4(address):

View file

@ -1,4 +1,4 @@
from lbrynet.dht import constants from . import constants
class Distance: class Distance:

View file

@ -7,7 +7,7 @@
# The docstrings in this module contain epytext markup; API documentation # The docstrings in this module contain epytext markup; API documentation
# may be created by processing this file with epydoc: http://epydoc.sf.net # may be created by processing this file with epydoc: http://epydoc.sf.net
from lbrynet.p2p.utils import generate_id from lbrynet.utils import generate_id
from . import constants from . import constants

View file

@ -5,9 +5,8 @@ from functools import reduce
from twisted.internet import defer, error, task from twisted.internet import defer, error, task
from lbrynet.p2p.utils import generate_id, DeferredDict from lbrynet.utils import generate_id, DeferredDict
from lbrynet.p2p.call_later_manager import CallLaterManager from .call_later_manager import CallLaterManager
from lbrynet.p2p.PeerManager import PeerManager
from .error import TimeoutError from .error import TimeoutError
from . import constants from . import constants
from . import routingtable from . import routingtable

View file

@ -24,7 +24,7 @@ from lbrynet.extras.daemon.Daemon import Daemon
from lbrynet.extras.daemon.DaemonControl import start as daemon_main from lbrynet.extras.daemon.DaemonControl import start as daemon_main
from lbrynet.extras.daemon.DaemonConsole import main as daemon_console from lbrynet.extras.daemon.DaemonConsole import main as daemon_console
from lbrynet.extras.daemon.auth.client import LBRYAPIClient from lbrynet.extras.daemon.auth.client import LBRYAPIClient
from lbrynet.p2p.system_info import get_platform from lbrynet.system_info import get_platform
async def execute_command(method, params, conf_path=None): async def execute_command(method, params, conf_path=None):

View file

@ -1,8 +1,8 @@
import logging import logging
from twisted.internet import defer from twisted.internet import defer
from lbrynet.p2p.Error import ComponentStartConditionNotMet from lbrynet.p2p.Error import ComponentStartConditionNotMet
from lbrynet.core.PeerManager import PeerManager from .PeerManager import PeerManager
from lbrynet.dht.peerfinder import DHTPeerFinder from .PeerFinder import DHTPeerFinder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -11,8 +11,8 @@ import lbrynet.schema
from aioupnp import __version__ as aioupnp_version from aioupnp import __version__ as aioupnp_version
from aioupnp.upnp import UPnP from aioupnp.upnp import UPnP
from aioupnp.fault import UPnPError from aioupnp.fault import UPnPError
from lbrynet.extras.daemon import conf from lbrynet import conf, system_info
from lbrynet.p2p.utils import DeferredDict from lbrynet.utils import DeferredDict, generate_id
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.p2p.RateLimiter import RateLimiter from lbrynet.p2p.RateLimiter import RateLimiter
from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.BlobManager import DiskBlobManager
@ -23,16 +23,15 @@ from lbrynet.p2p.server.BlobRequestHandler import BlobRequestHandlerFactory
from lbrynet.p2p.server.ServerProtocol import ServerProtocolFactory from lbrynet.p2p.server.ServerProtocol import ServerProtocolFactory
from .Component import Component from .Component import Component
from .ExchangeRateManager import ExchangeRateManager from .ExchangeRateManager import ExchangeRateManager
from lbrynet.extras.daemon.storage import SQLiteStorage from .storage import SQLiteStorage
from lbrynet.dht import node from .HashAnnouncer import DHTHashAnnouncer
from lbrynet.extras.daemon.HashAnnouncer import DHTHashAnnouncer
from lbrynet.dht.node import Node
from lbrynet.blob.EncryptedFileManager import EncryptedFileManager from lbrynet.blob.EncryptedFileManager import EncryptedFileManager
from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaverFactory from lbrynet.blob.client.EncryptedFileDownloader import EncryptedFileSaverFactory
from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
from lbrynet.extras.reflector import ServerFactory as reflector_server_factory from lbrynet.extras.reflector import ServerFactory as reflector_server_factory
from lbrynet.p2p.utils import generate_id
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
# settings must be initialized before this file is imported # settings must be initialized before this file is imported
@ -95,8 +94,7 @@ class ConfigSettings:
@staticmethod @staticmethod
def get_external_ip(): def get_external_ip():
from lbrynet.p2p.system_info import get_platform platform = system_info.get_platform(get_ip=True)
platform = get_platform(get_ip=True)
return platform['ip'] return platform['ip']
@ -435,7 +433,7 @@ class DHTComponent(Component):
if not external_ip: if not external_ip:
log.warning("failed to get external ip") log.warning("failed to get external ip")
self.dht_node = node.Node( self.dht_node = Node(
node_id=node_id, node_id=node_id,
udpPort=GCS('dht_node_port'), udpPort=GCS('dht_node_port'),
externalUDPPort=self.external_udp_port, externalUDPPort=self.external_udp_port,

View file

@ -16,6 +16,8 @@ from twisted.python.failure import Failure
from torba.client.baseaccount import SingleKey, HierarchicalDeterministic from torba.client.baseaccount import SingleKey, HierarchicalDeterministic
from lbrynet import conf, utils, system_info
from lbrynet.system_info import get_lbrynet_version
from lbrynet.schema.claim import ClaimDict from lbrynet.schema.claim import ClaimDict
from lbrynet.schema.uri import parse_lbry_uri from lbrynet.schema.uri import parse_lbry_uri
from lbrynet.schema.error import URIParseError, DecodeError from lbrynet.schema.error import URIParseError, DecodeError
@ -23,19 +25,15 @@ from lbrynet.schema.validator import validate_claim_id
from lbrynet.schema.address import decode_address from lbrynet.schema.address import decode_address
from lbrynet.schema.decode import smart_decode from lbrynet.schema.decode import smart_decode
# TODO: importing this when internet is disabled raises a socket.gaierror
from lbrynet.p2p.system_info import get_lbrynet_version
from lbrynet.extras.daemon import conf
from lbrynet.extras.reflector import reupload from lbrynet.extras.reflector import reupload
from .Components import d2f, f2d from .Components import d2f, f2d
from .Components import WALLET_COMPONENT, DATABASE_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT from .Components import WALLET_COMPONENT, DATABASE_COMPONENT, DHT_COMPONENT, BLOB_COMPONENT
from .Components import STREAM_IDENTIFIER_COMPONENT, FILE_MANAGER_COMPONENT, RATE_LIMITER_COMPONENT from .Components import FILE_MANAGER_COMPONENT, RATE_LIMITER_COMPONENT
from .Components import EXCHANGE_RATE_MANAGER_COMPONENT, PAYMENT_RATE_COMPONENT, UPNP_COMPONENT from .Components import EXCHANGE_RATE_MANAGER_COMPONENT, PAYMENT_RATE_COMPONENT, UPNP_COMPONENT
from .ComponentManager import RequiredCondition from .ComponentManager import RequiredCondition
from .Downloader import GetStream from .Downloader import GetStream
from .Publisher import Publisher from .Publisher import Publisher
from .auth.server import AuthJSONRPCServer from .auth.server import AuthJSONRPCServer
from lbrynet.p2p import utils, system_info
from lbrynet.p2p.StreamDescriptor import download_sd_blob from lbrynet.p2p.StreamDescriptor import download_sd_blob
from lbrynet.p2p.Error import InsufficientFundsError, UnknownNameError from lbrynet.p2p.Error import InsufficientFundsError, UnknownNameError
from lbrynet.p2p.Error import DownloadDataTimeout, DownloadSDTimeout from lbrynet.p2p.Error import DownloadDataTimeout, DownloadSDTimeout
@ -448,7 +446,7 @@ class Daemon(AuthJSONRPCServer):
Get total stream size in bytes from a sd blob Get total stream size in bytes from a sd blob
""" """
d = self.sd_identifier.get_metadata_for_sd_blob(sd_blob) d = self.file_manager.sd_identifier.get_metadata_for_sd_blob(sd_blob)
d.addCallback(lambda metadata: metadata.validator.info_to_show()) d.addCallback(lambda metadata: metadata.validator.info_to_show())
d.addCallback(lambda info: int(dict(info)['stream_size'])) d.addCallback(lambda info: int(dict(info)['stream_size']))
return d return d
@ -466,9 +464,7 @@ class Daemon(AuthJSONRPCServer):
""" """
Calculate estimated LBC cost for a stream given its size in bytes Calculate estimated LBC cost for a stream given its size in bytes
""" """
cost = self._get_est_cost_from_stream_size(size) cost = self._get_est_cost_from_stream_size(size)
resolved = await self.wallet_manager.resolve(uri) resolved = await self.wallet_manager.resolve(uri)
if uri in resolved and 'claim' in resolved[uri]: if uri in resolved and 'claim' in resolved[uri]:
@ -533,7 +529,6 @@ class Daemon(AuthJSONRPCServer):
sd blob will be downloaded to determine the stream size sd blob will be downloaded to determine the stream size
""" """
if size is not None: if size is not None:
return self.get_est_cost_using_known_size(uri, size) return self.get_est_cost_using_known_size(uri, size)
return self.get_est_cost_from_uri(uri) return self.get_est_cost_from_uri(uri)

View file

@ -6,9 +6,9 @@ import logging.handlers
from twisted.internet import defer, reactor, threads from twisted.internet import defer, reactor, threads
from aiohttp import client_exceptions from aiohttp import client_exceptions
from lbrynet.extras.daemon import analytics, conf from lbrynet.extras.daemon import analytics
from lbrynet.p2p import utils from lbrynet import utils, conf
from lbrynet.p2p import log_support from lbrynet import log_support
from .auth.client import LBRYAPIClient from .auth.client import LBRYAPIClient
from .Daemon import Daemon from .Daemon import Daemon

View file

@ -7,15 +7,14 @@ if 'win' in sys.platform:
import certifi import certifi
os.environ['SSL_CERT_FILE'] = certifi.where() os.environ['SSL_CERT_FILE'] = certifi.where()
from lbrynet.p2p import log_support from lbrynet import log_support
import argparse import argparse
import logging.handlers import logging.handlers
from twisted.internet import reactor from twisted.internet import reactor
from lbrynet.extras.daemon import conf from lbrynet import utils, system_info, conf
from lbrynet.p2p import utils, system_info
from .Daemon import Daemon from .Daemon import Daemon
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -4,14 +4,14 @@ from twisted.internet import defer
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall
from .Components import f2d from .Components import f2d
from lbrynet import conf
from lbrynet.schema.fee import Fee from lbrynet.schema.fee import Fee
from lbrynet.p2p.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed, InvalidStreamDescriptorError from lbrynet.p2p.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed, InvalidStreamDescriptorError
from lbrynet.p2p.Error import DownloadDataTimeout, DownloadCanceledError, DownloadSDTimeout from lbrynet.p2p.Error import DownloadDataTimeout, DownloadCanceledError, DownloadSDTimeout
from lbrynet.p2p.utils import safe_start_looping_call, safe_stop_looping_call from lbrynet.utils import safe_start_looping_call, safe_stop_looping_call
from lbrynet.p2p.StreamDescriptor import download_sd_blob from lbrynet.p2p.StreamDescriptor import download_sd_blob
from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory
from lbrynet.extras.daemon import conf
from torba.client.constants import COIN from torba.client.constants import COIN
from lbrynet.extras.wallet.dewies import dewies_to_lbc from lbrynet.extras.wallet.dewies import dewies_to_lbc

View file

@ -2,8 +2,7 @@ import binascii
import logging import logging
from twisted.internet import defer, task from twisted.internet import defer, task
from lbrynet.p2p import utils from lbrynet import utils, conf
from lbrynet.extras.daemon import conf
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -2,7 +2,7 @@ import binascii
import logging import logging
from twisted.internet import defer from twisted.internet import defer
from lbrynet.extras.daemon import conf from lbrynet import conf
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -4,8 +4,8 @@ import logging
import treq import treq
from twisted.internet import defer, task from twisted.internet import defer, task
from lbrynet.extras.daemon import conf from lbrynet import conf, utils, system_info
from lbrynet.p2p import looping_call_manager, utils, system_info from lbrynet.extras import looping_call_manager
# Things We Track # Things We Track
SERVER_STARTUP = 'Server Startup' SERVER_STARTUP = 'Server Startup'

View file

@ -3,7 +3,7 @@ import aiohttp
import logging import logging
from urllib.parse import urlparse from urllib.parse import urlparse
from lbrynet.extras.daemon import conf from lbrynet import conf
from .keyring import Keyring, APIKey from .keyring import Keyring, APIKey
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -3,7 +3,7 @@ import logging
from twisted.web import server, guard, resource from twisted.web import server, guard, resource
from twisted.cred import portal from twisted.cred import portal
from lbrynet.extras.daemon import conf from lbrynet import conf
from .auth import PasswordChecker, HttpPasswordRealm from .auth import PasswordChecker, HttpPasswordRealm
from ..auth.keyring import Keyring from ..auth.keyring import Keyring

View file

@ -13,7 +13,7 @@ from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
from twisted.internet import ssl from twisted.internet import ssl
import logging import logging
from lbrynet.extras.daemon import conf from lbrynet import conf
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -13,12 +13,11 @@ from twisted.python.failure import Failure
from twisted.internet.error import ConnectionDone, ConnectionLost from twisted.internet.error import ConnectionDone, ConnectionLost
from txjsonrpc import jsonrpclib from txjsonrpc import jsonrpclib
from traceback import format_exc from traceback import format_exc
from lbrynet import conf, utils
from lbrynet.extras.daemon import analytics, conf from lbrynet.extras.daemon import analytics
from lbrynet.p2p.Error import InvalidAuthenticationToken from lbrynet.p2p.Error import InvalidAuthenticationToken
from lbrynet.p2p import utils
from lbrynet.p2p.Error import ComponentsNotStarted, ComponentStartConditionNotMet from lbrynet.p2p.Error import ComponentsNotStarted, ComponentStartConditionNotMet
from lbrynet.p2p.looping_call_manager import LoopingCallManager from lbrynet.extras.looping_call_manager import LoopingCallManager
from lbrynet.extras.daemon.ComponentManager import ComponentManager from lbrynet.extras.daemon.ComponentManager import ComponentManager
from .keyring import APIKey, Keyring from .keyring import APIKey, Keyring
from .undecorated import undecorated from .undecorated import undecorated

View file

@ -3,7 +3,7 @@ import os
import json import json
import logging import logging
from lbrynet.schema.decode import smart_decode from lbrynet.schema.decode import smart_decode
from lbrynet.extras.daemon import conf from lbrynet import conf
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -6,10 +6,9 @@ from binascii import hexlify, unhexlify
from decimal import Decimal from decimal import Decimal
from twisted.internet import defer, task, threads from twisted.internet import defer, task, threads
from twisted.enterprise import adbapi from twisted.enterprise import adbapi
from lbrynet import conf
from lbrynet.schema.claim import ClaimDict from lbrynet.schema.claim import ClaimDict
from lbrynet.schema.decode import smart_decode from lbrynet.schema.decode import smart_decode
from lbrynet.extras.daemon import conf
from lbrynet.blob.CryptBlob import CryptBlobInfo from lbrynet.blob.CryptBlob import CryptBlobInfo
from lbrynet.dht.constants import dataExpireTimeout from lbrynet.dht.constants import dataExpireTimeout
from torba.client.constants import COIN from torba.client.constants import COIN

View file

@ -1,7 +1,7 @@
import random import random
from twisted.internet import reactor, defer from twisted.internet import reactor, defer
from lbrynet.extras.daemon import conf from lbrynet import conf
from . import ClientFactory, BlobClientFactory from . import ClientFactory, BlobClientFactory

View file

@ -3,7 +3,7 @@ import json
from twisted.python import failure from twisted.python import failure
from twisted.internet import error, defer from twisted.internet import error, defer
from twisted.internet.protocol import Protocol, ServerFactory from twisted.internet.protocol import Protocol, ServerFactory
from lbrynet.p2p.utils import is_valid_blobhash from lbrynet.utils import is_valid_blobhash
from lbrynet.p2p.Error import DownloadCanceledError, InvalidBlobHashError from lbrynet.p2p.Error import DownloadCanceledError, InvalidBlobHashError
from lbrynet.p2p.StreamDescriptor import BlobStreamDescriptorReader from lbrynet.p2p.StreamDescriptor import BlobStreamDescriptorReader
from lbrynet.p2p.StreamDescriptor import save_sd_info from lbrynet.p2p.StreamDescriptor import save_sd_info

View file

@ -3,14 +3,11 @@ import logging
import logging.handlers import logging.handlers
import sys import sys
import traceback import traceback
import treq import treq
from twisted.internet import defer
import twisted.python.log import twisted.python.log
from twisted.internet import defer
from lbrynet import __version__ as lbrynet_version, build_type from lbrynet import __version__ as lbrynet_version, build_type
from lbrynet.extras.daemon import conf from lbrynet import utils, conf
from lbrynet.p2p import utils
class HTTPSHandler(logging.Handler): class HTTPSHandler(logging.Handler):
@ -214,6 +211,7 @@ def configure_logging(file_name, console, verbose=None):
verbose: a list of loggers to set to debug level. verbose: a list of loggers to set to debug level.
See `convert_verbose` for more details. See `convert_verbose` for more details.
""" """
logger = logging.getLoggerClass()
verbose = convert_verbose(verbose) verbose = convert_verbose(verbose)
configure_twisted() configure_twisted()
configure_file_handler(file_name) configure_file_handler(file_name)

View file

@ -4,7 +4,7 @@ from twisted.internet import defer, task
from twisted.internet.error import ConnectingCancelledError from twisted.internet.error import ConnectingCancelledError
from twisted.web._newclient import ResponseNeverReceived from twisted.web._newclient import ResponseNeverReceived
import treq import treq
from lbrynet.p2p.utils import DeferredDict from lbrynet.utils import DeferredDict
from lbrynet.p2p.Error import DownloadCanceledError from lbrynet.p2p.Error import DownloadCanceledError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,5 +1,5 @@
from lbrynet.p2p.Strategy import get_default_strategy, OnlyFreeStrategy from lbrynet.p2p.Strategy import get_default_strategy, OnlyFreeStrategy
from lbrynet.extras.daemon import conf from lbrynet import conf
from decimal import Decimal from decimal import Decimal

View file

@ -1,6 +1,6 @@
import datetime import datetime
from collections import defaultdict from collections import defaultdict
from lbrynet.p2p import utils from lbrynet import utils
# Do not create this object except through PeerManager # Do not create this object except through PeerManager
class Peer: class Peer:

View file

@ -1,6 +1,5 @@
from decimal import Decimal from decimal import Decimal
from lbrynet import conf
from lbrynet.extras.daemon import conf
def get_default_price_model(blob_tracker, base_price, **kwargs): def get_default_price_model(blob_tracker, base_price, **kwargs):

View file

@ -12,7 +12,7 @@ from lbrynet.p2p.client.BlobRequester import BlobRequester
from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader
from lbrynet.p2p.client.ConnectionManager import ConnectionManager from lbrynet.p2p.client.ConnectionManager import ConnectionManager
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.dht.peerfinder import DummyPeerFinder from lbrynet.extras.daemon.PeerFinder import DummyPeerFinder
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,5 +1,5 @@
from decimal import Decimal from decimal import Decimal
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.p2p.Offer import Offer from lbrynet.p2p.Offer import Offer
from lbrynet.p2p.PriceModel import MeanAvailabilityWeightedPrice, ZeroPrice from lbrynet.p2p.PriceModel import MeanAvailabilityWeightedPrice, ZeroPrice
@ -133,7 +133,6 @@ class BasicAvailabilityWeightedStrategy(Strategy):
class OnlyFreeStrategy(Strategy): class OnlyFreeStrategy(Strategy):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
price_model = ZeroPrice() price_model = ZeroPrice()
super().__init__(price_model, 0.0, 0.0, True) super().__init__(price_model, 0.0, 0.0, True)

View file

@ -5,7 +5,7 @@ import json
import logging import logging
from twisted.internet import threads, defer from twisted.internet import threads, defer
from lbrynet.p2p.cryptoutils import get_lbry_hash_obj from lbrynet.cryptoutils import get_lbry_hash_obj
from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader from lbrynet.p2p.client.StandaloneBlobDownloader import StandaloneBlobDownloader
from lbrynet.p2p.Error import UnknownStreamTypeError, InvalidStreamDescriptorError from lbrynet.p2p.Error import UnknownStreamTypeError, InvalidStreamDescriptorError
from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader

View file

@ -5,8 +5,7 @@ from twisted.internet import error, defer
from twisted.internet.protocol import Protocol, ClientFactory from twisted.internet.protocol import Protocol, ClientFactory
from twisted.protocols.policies import TimeoutMixin from twisted.protocols.policies import TimeoutMixin
from twisted.python import failure from twisted.python import failure
from lbrynet.extras.daemon import conf from lbrynet import conf, utils
from lbrynet.p2p import utils
from lbrynet.p2p.Error import ConnectionClosedBeforeResponseError, NoResponseError from lbrynet.p2p.Error import ConnectionClosedBeforeResponseError, NoResponseError
from lbrynet.p2p.Error import DownloadCanceledError, MisbehavingPeerError from lbrynet.p2p.Error import DownloadCanceledError, MisbehavingPeerError
from lbrynet.p2p.Error import RequestCanceledError from lbrynet.p2p.Error import RequestCanceledError

View file

@ -1,10 +1,9 @@
import random import random
import logging import logging
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from lbrynet.extras.daemon import conf from lbrynet import utils, conf
from lbrynet.p2p.client.ClientProtocol import ClientProtocolFactory from lbrynet.p2p.client.ClientProtocol import ClientProtocolFactory
from lbrynet.p2p.Error import InsufficientFundsError from lbrynet.p2p.Error import InsufficientFundsError
from lbrynet.p2p import utils
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -4,7 +4,7 @@ from lbrynet.p2p.client.BlobRequester import BlobRequester
from lbrynet.p2p.client.ConnectionManager import ConnectionManager from lbrynet.p2p.client.ConnectionManager import ConnectionManager
from lbrynet.p2p.client.DownloadManager import DownloadManager from lbrynet.p2p.client.DownloadManager import DownloadManager
from lbrynet.p2p.Error import InvalidBlobHashError, DownloadSDTimeout from lbrynet.p2p.Error import InvalidBlobHashError, DownloadSDTimeout
from lbrynet.p2p.utils import is_valid_blobhash, safe_start_looping_call, safe_stop_looping_call from lbrynet.utils import is_valid_blobhash, safe_start_looping_call, safe_stop_looping_call
from twisted.python.failure import Failure from twisted.python.failure import Failure
from twisted.internet import defer from twisted.internet import defer
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall

View file

@ -12,7 +12,7 @@ import pkg_resources
from twisted.python.failure import Failure from twisted.python.failure import Failure
from twisted.internet import defer from twisted.internet import defer
from lbrynet.schema.claim import ClaimDict from lbrynet.schema.claim import ClaimDict
from lbrynet.p2p.cryptoutils import get_lbry_hash_obj from lbrynet.cryptoutils import get_lbry_hash_obj
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -52,6 +52,7 @@ def call_later(delay, func, *args, **kwargs):
from twisted.internet import reactor from twisted.internet import reactor
return reactor.callLater(delay, func, *args, **kwargs) return reactor.callLater(delay, func, *args, **kwargs)
def safe_start_looping_call(looping_call, interval_sec): def safe_start_looping_call(looping_call, interval_sec):
if not looping_call.running: if not looping_call.running:
looping_call.start(interval_sec) looping_call.start(interval_sec)

View file

@ -9,7 +9,7 @@ from twisted.web.client import FileBodyProducer
from lbrynet import conf from lbrynet import conf
from lbrynet.core import log_support from lbrynet.core import log_support
from lbrynet.dht.hashannouncer import DummyHashAnnouncer from lbrynet.extras.daemon.HashAnnouncer import DHTHashAnnouncer
from lbrynet.core.BlobManager import DiskBlobManager from lbrynet.core.BlobManager import DiskBlobManager
from lbrynet.cryptstream.CryptStreamCreator import CryptStreamCreator from lbrynet.cryptstream.CryptStreamCreator import CryptStreamCreator

View file

@ -2,13 +2,13 @@ import os
from hashlib import md5 from hashlib import md5
from twisted.internet import defer, reactor from twisted.internet import defer, reactor
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.p2p.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory from lbrynet.p2p.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier
from lbrynet.p2p.StreamDescriptor import download_sd_blob from lbrynet.p2p.StreamDescriptor import download_sd_blob
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.BlobManager import DiskBlobManager
from lbrynet.p2p.PeerManager import PeerManager from lbrynet.extras.daemon.PeerManager import PeerManager
from lbrynet.p2p.RateLimiter import RateLimiter from lbrynet.p2p.RateLimiter import RateLimiter
from lbrynet.p2p.server.BlobRequestHandler import BlobRequestHandlerFactory from lbrynet.p2p.server.BlobRequestHandler import BlobRequestHandlerFactory
from lbrynet.p2p.server.ServerProtocol import ServerProtocolFactory from lbrynet.p2p.server.ServerProtocol import ServerProtocolFactory
@ -18,7 +18,7 @@ from lbrynet.blob.EncryptedFileManager import EncryptedFileManager
from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier from lbrynet.blob.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
from tests import mocks from tests import mocks
from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir
FakeNode = mocks.Node FakeNode = mocks.Node
FakeWallet = mocks.Wallet FakeWallet = mocks.Wallet

View file

@ -5,7 +5,8 @@ from twisted.internet import defer, error
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.p2p.StreamDescriptor import get_sd_info from lbrynet.p2p.StreamDescriptor import get_sd_info
from lbrynet.extras import reflector from lbrynet.extras import reflector
from lbrynet.p2p import BlobManager, PeerManager from lbrynet.extras.daemon.PeerManager import PeerManager
from lbrynet.p2p import BlobManager
from lbrynet.p2p import StreamDescriptor from lbrynet.p2p import StreamDescriptor
from lbrynet.blob import EncryptedFileCreator from lbrynet.blob import EncryptedFileCreator
from lbrynet.blob.EncryptedFileManager import EncryptedFileManager from lbrynet.blob.EncryptedFileManager import EncryptedFileManager
@ -13,7 +14,7 @@ from lbrynet.p2p.RateLimiter import DummyRateLimiter
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from tests import mocks from tests import mocks
from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir
class TestReflector(unittest.TestCase): class TestReflector(unittest.TestCase):

View file

@ -7,8 +7,8 @@ from twisted.internet import defer, threads
from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier
from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.BlobManager import DiskBlobManager
from lbrynet.p2p.StreamDescriptor import get_sd_info from lbrynet.p2p.StreamDescriptor import get_sd_info
from lbrynet.p2p.PeerManager import PeerManager
from lbrynet.p2p.RateLimiter import DummyRateLimiter from lbrynet.p2p.RateLimiter import DummyRateLimiter
from lbrynet.extras.daemon.PeerManager import PeerManager
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.blob.EncryptedFileCreator import create_lbry_file from lbrynet.blob.EncryptedFileCreator import create_lbry_file

View file

@ -4,7 +4,7 @@ from io import StringIO
from twisted.internet import defer from twisted.internet import defer
from lbrynet import conf from lbrynet import conf
from lbrynet import cli from lbrynet.extras import cli
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \ from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, BLOB_COMPONENT, HEADERS_COMPONENT, WALLET_COMPONENT, \
DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, \ DHT_COMPONENT, HASH_ANNOUNCER_COMPONENT, FILE_MANAGER_COMPONENT, \
PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, \ PEER_PROTOCOL_SERVER_COMPONENT, REFLECTOR_COMPONENT, UPNP_COMPONENT, EXCHANGE_RATE_MANAGER_COMPONENT, \

View file

@ -15,7 +15,7 @@ from torba.testcase import IntegrationTestCase as BaseIntegrationTestCase
import lbrynet.schema import lbrynet.schema
lbrynet.schema.BLOCKCHAIN_NAME = 'lbrycrd_regtest' lbrynet.schema.BLOCKCHAIN_NAME = 'lbrycrd_regtest'
from lbrynet.extras.daemon import conf as lbry_conf from lbrynet import conf as lbry_conf
from lbrynet.dht.node import Node from lbrynet.dht.node import Node
from lbrynet.extras.daemon.Daemon import Daemon from lbrynet.extras.daemon.Daemon import Daemon
from lbrynet.extras.wallet import LbryWalletManager from lbrynet.extras.wallet import LbryWalletManager

View file

@ -7,13 +7,13 @@ from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.primitives import serialization from cryptography.hazmat.primitives import serialization
from twisted.internet import defer from twisted.internet import defer
from twisted.python.failure import Failure from twisted.python.failure import Failure
from lbrynet import conf
from lbrynet.p2p.client.ClientRequest import ClientRequest from lbrynet.p2p.client.ClientRequest import ClientRequest
from lbrynet.p2p.Error import RequestCanceledError from lbrynet.p2p.Error import RequestCanceledError
from lbrynet.p2p import BlobAvailability from lbrynet.p2p import BlobAvailability
from lbrynet.blob.EncryptedFileManager import EncryptedFileManager from lbrynet.blob.EncryptedFileManager import EncryptedFileManager
from lbrynet.dht.node import Node as RealNode from lbrynet.dht.node import Node as RealNode
from lbrynet.extras.daemon import ExchangeRateManager as ERM, conf from lbrynet.extras.daemon import ExchangeRateManager as ERM
KB = 2**10 KB = 2**10
PUBLIC_EXPONENT = 65537 # http://www.daemonology.net/blog/2009-06-11-cryptographic-right-answers.html PUBLIC_EXPONENT = 65537 # http://www.daemonology.net/blog/2009-06-11-cryptographic-right-answers.html

View file

@ -32,13 +32,14 @@ def resetTime(test_case, timestamp=DEFAULT_TIMESTAMP):
patcher.start().return_value = iso_time patcher.start().return_value = iso_time
test_case.addCleanup(patcher.stop) test_case.addCleanup(patcher.stop)
patcher = mock.patch('lbrynet.p2p.utils.now') patcher = mock.patch('lbrynet.utils.now')
patcher.start().return_value = timestamp patcher.start().return_value = timestamp
test_case.addCleanup(patcher.stop) test_case.addCleanup(patcher.stop)
patcher = mock.patch('lbrynet.p2p.utils.utcnow') patcher = mock.patch('lbrynet.utils.utcnow')
patcher.start().return_value = timestamp patcher.start().return_value = timestamp
test_case.addCleanup(patcher.stop) test_case.addCleanup(patcher.stop)
def is_android(): def is_android():
return 'ANDROID_ARGUMENT' in os.environ # detect Android using the Kivy way return 'ANDROID_ARGUMENT' in os.environ # detect Android using the Kivy way

View file

@ -1,17 +1,16 @@
from twisted.trial.unittest import TestCase
from twisted.internet import defer, reactor, task
from twisted.internet.task import deferLater
from twisted.internet.protocol import ServerFactory
from lbrynet import conf, utils
from lbrynet.p2p.client.ClientRequest import ClientRequest from lbrynet.p2p.client.ClientRequest import ClientRequest
from lbrynet.p2p.server.ServerProtocol import ServerProtocol from lbrynet.p2p.server.ServerProtocol import ServerProtocol
from lbrynet.p2p.client.ClientProtocol import ClientProtocol from lbrynet.p2p.client.ClientProtocol import ClientProtocol
from lbrynet.p2p.RateLimiter import RateLimiter from lbrynet.p2p.RateLimiter import RateLimiter
from lbrynet.p2p.Peer import Peer from lbrynet.p2p.Peer import Peer
from lbrynet.p2p.PeerManager import PeerManager
from lbrynet.p2p.Error import NoResponseError from lbrynet.p2p.Error import NoResponseError
from lbrynet.extras.daemon.PeerManager import PeerManager
from twisted.trial.unittest import TestCase
from twisted.internet import defer, reactor, task
from twisted.internet.task import deferLater
from twisted.internet.protocol import ServerFactory
from lbrynet.extras.daemon import conf
from lbrynet.p2p import utils
PEER_PORT = 5551 PEER_PORT = 5551
LOCAL_HOST = '127.0.0.1' LOCAL_HOST = '127.0.0.1'

View file

@ -6,12 +6,12 @@ import string
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from tests.util import random_lbry_hash from tests.test_utils import random_lbry_hash
from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.BlobManager import DiskBlobManager
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.p2p.Peer import Peer from lbrynet.p2p.Peer import Peer
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.p2p.cryptoutils import get_lbry_hash_obj from lbrynet.cryptoutils import get_lbry_hash_obj
class BlobManagerTest(unittest.TestCase): class BlobManagerTest(unittest.TestCase):

View file

@ -5,7 +5,7 @@ from twisted.internet import defer
from lbrynet.blob import BlobFile from lbrynet.blob import BlobFile
from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader from lbrynet.p2p.HTTPBlobDownloader import HTTPBlobDownloader
from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir
class HTTPBlobDownloaderTest(unittest.TestCase): class HTTPBlobDownloaderTest(unittest.TestCase):

View file

@ -1,7 +1,7 @@
from lbrynet.blob import BlobFile from lbrynet.blob import BlobFile
from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError from lbrynet.p2p.Error import DownloadCanceledError, InvalidDataError
from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir, random_lbry_hash from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir, random_lbry_hash
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer

View file

@ -5,9 +5,6 @@ from decimal import Decimal
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from lbrynet.p2p.Error import InsufficientFundsError from lbrynet.p2p.Error import InsufficientFundsError
#from lbrynet.p2p.Wallet import LBRYumWallet, ReservedPoints
#from lbryum.commands import Commands
#from lbryum.simple_config import SimpleConfig
from lbrynet.schema.claim import ClaimDict from lbrynet.schema.claim import ClaimDict
test_metadata = { test_metadata = {

View file

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from lbrynet.p2p import utils from lbrynet import utils
from twisted.trial import unittest from twisted.trial import unittest

View file

@ -5,10 +5,10 @@ import logging
from copy import deepcopy from copy import deepcopy
from twisted.internet import defer from twisted.internet import defer
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.extras.daemon.storage import SQLiteStorage, open_file_for_writing from lbrynet.extras.daemon.storage import SQLiteStorage, open_file_for_writing
from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader
from tests.util import random_lbry_hash from tests.test_utils import random_lbry_hash
log = logging.getLogger() log = logging.getLogger()

View file

@ -1,7 +1,7 @@
from binascii import hexlify from binascii import hexlify
from twisted.internet import task from twisted.internet import task
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.p2p.utils import generate_id from lbrynet.utils import generate_id
from lbrynet.dht.contact import ContactManager from lbrynet.dht.contact import ContactManager
from lbrynet.dht import constants from lbrynet.dht import constants

View file

@ -1,8 +1,8 @@
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer, task from twisted.internet import defer, task
from lbrynet.p2p import utils from lbrynet import utils
from lbrynet.extras.daemon.HashAnnouncer import DHTHashAnnouncer from lbrynet.extras.daemon.HashAnnouncer import DHTHashAnnouncer
from tests.util import random_lbry_hash from tests.test_utils import random_lbry_hash
from tests.mocks import mock_conf_settings from tests.mocks import mock_conf_settings

View file

@ -6,7 +6,7 @@
from twisted.trial import unittest from twisted.trial import unittest
import struct import struct
from lbrynet.p2p.utils import generate_id from lbrynet.utils import generate_id
from lbrynet.dht import kbucket from lbrynet.dht import kbucket
from lbrynet.dht.contact import ContactManager from lbrynet.dht.contact import ContactManager
from lbrynet.dht import constants from lbrynet.dht import constants

View file

@ -5,7 +5,7 @@ from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from lbrynet.dht.node import Node from lbrynet.dht.node import Node
from lbrynet.dht import constants from lbrynet.dht import constants
from lbrynet.p2p.utils import generate_id from lbrynet.utils import generate_id
class NodeIDTest(unittest.TestCase): class NodeIDTest(unittest.TestCase):

View file

@ -6,7 +6,7 @@ from lbrynet.dht import constants
from lbrynet.dht.routingtable import TreeRoutingTable from lbrynet.dht.routingtable import TreeRoutingTable
from lbrynet.dht.contact import ContactManager from lbrynet.dht.contact import ContactManager
from lbrynet.dht.distance import Distance from lbrynet.dht.distance import Distance
from lbrynet.p2p.utils import generate_id from lbrynet.utils import generate_id
class FakeRPCProtocol: class FakeRPCProtocol:

View file

@ -3,10 +3,10 @@ from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from cryptography.hazmat.primitives.ciphers.algorithms import AES from cryptography.hazmat.primitives.ciphers.algorithms import AES
from lbrynet.extras.daemon.PeerManager import PeerManager
from lbrynet.p2p.StreamDescriptor import get_sd_info, BlobStreamDescriptorReader from lbrynet.p2p.StreamDescriptor import get_sd_info, BlobStreamDescriptorReader
from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier from lbrynet.p2p.StreamDescriptor import StreamDescriptorIdentifier
from lbrynet.p2p.BlobManager import DiskBlobManager from lbrynet.p2p.BlobManager import DiskBlobManager
from lbrynet.p2p.PeerManager import PeerManager
from lbrynet.p2p.RateLimiter import DummyRateLimiter from lbrynet.p2p.RateLimiter import DummyRateLimiter
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
@ -14,7 +14,7 @@ from lbrynet.blob import EncryptedFileCreator
from lbrynet.blob.EncryptedFileManager import EncryptedFileManager from lbrynet.blob.EncryptedFileManager import EncryptedFileManager
from lbrynet.p2p.StreamDescriptor import JSONBytesEncoder from lbrynet.p2p.StreamDescriptor import JSONBytesEncoder
from tests import mocks from tests import mocks
from tests.util import mk_db_and_blob_dir, rm_db_and_blob_dir from tests.test_utils import mk_db_and_blob_dir, rm_db_and_blob_dir
FakeNode = mocks.Node FakeNode = mocks.Node

View file

@ -1,7 +1,7 @@
import mock import mock
from twisted.internet import reactor from twisted.internet import reactor
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.extras.daemon.auth import server from lbrynet.extras.daemon.auth import server
from tests.mocks import mock_conf_settings from tests.mocks import mock_conf_settings

View file

@ -7,9 +7,8 @@ from twisted.internet import defer
from twisted.trial import unittest from twisted.trial import unittest
from faker import Faker from faker import Faker
from lbrynet import conf
from lbrynet.schema.decode import smart_decode from lbrynet.schema.decode import smart_decode
from lbrynet.extras.daemon import conf
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.extras.daemon.ComponentManager import ComponentManager from lbrynet.extras.daemon.ComponentManager import ComponentManager
from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, DHT_COMPONENT, WALLET_COMPONENT from lbrynet.extras.daemon.Components import DATABASE_COMPONENT, DHT_COMPONENT, WALLET_COMPONENT
@ -23,24 +22,19 @@ from lbrynet.extras.wallet import LbryWalletManager
from torba.client.wallet import Wallet from torba.client.wallet import Wallet
from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager from lbrynet.p2p.PaymentRateManager import OnlyFreePaymentsManager
from tests import util from tests import test_utils
from tests.mocks import mock_conf_settings, FakeNetwork, FakeFileManager from tests.mocks import mock_conf_settings, FakeNetwork, FakeFileManager
from tests.mocks import ExchangeRateManager as DummyExchangeRateManager from tests.mocks import ExchangeRateManager as DummyExchangeRateManager
from tests.mocks import BTCLBCFeed, USDBTCFeed from tests.mocks import BTCLBCFeed, USDBTCFeed
from tests.util import is_android from tests.test_utils import is_android
import logging
logging.getLogger("lbryum").setLevel(logging.WARNING)
def get_test_daemon(data_rate=None, generous=True, with_fee=False): def get_test_daemon(data_rate=None, generous=True, with_fee=False):
if data_rate is None: if data_rate is None:
data_rate = conf.ADJUSTABLE_SETTINGS['data_rate'][1] data_rate = conf.ADJUSTABLE_SETTINGS['data_rate'][1]
rates = { rates = {
'BTCLBC': {'spot': 3.0, 'ts': util.DEFAULT_ISO_TIME + 1}, 'BTCLBC': {'spot': 3.0, 'ts': test_utils.DEFAULT_ISO_TIME + 1},
'USDBTC': {'spot': 2.0, 'ts': util.DEFAULT_ISO_TIME + 2} 'USDBTC': {'spot': 2.0, 'ts': test_utils.DEFAULT_ISO_TIME + 2}
} }
component_manager = ComponentManager( component_manager = ComponentManager(
skip_components=[DATABASE_COMPONENT, DHT_COMPONENT, WALLET_COMPONENT, UPNP_COMPONENT, skip_components=[DATABASE_COMPONENT, DHT_COMPONENT, WALLET_COMPONENT, UPNP_COMPONENT,
@ -89,7 +83,7 @@ class TestCostEst(unittest.TestCase):
def setUp(self): def setUp(self):
mock_conf_settings(self) mock_conf_settings(self)
util.resetTime(self) test_utils.resetTime(self)
@defer.inlineCallbacks @defer.inlineCallbacks
def test_fee_and_generous_data(self): def test_fee_and_generous_data(self):
@ -134,7 +128,7 @@ class TestJsonRpc(unittest.TestCase):
return None return None
mock_conf_settings(self) mock_conf_settings(self)
util.resetTime(self) test_utils.resetTime(self)
self.test_daemon = get_test_daemon() self.test_daemon = get_test_daemon()
self.test_daemon.wallet_manager.is_first_run = False self.test_daemon.wallet_manager.is_first_run = False
self.test_daemon.wallet_manager.get_best_blockhash = noop self.test_daemon.wallet_manager.get_best_blockhash = noop
@ -156,7 +150,7 @@ class TestFileListSorting(unittest.TestCase):
def setUp(self): def setUp(self):
mock_conf_settings(self) mock_conf_settings(self)
util.resetTime(self) test_utils.resetTime(self)
self.faker = Faker('en_US') self.faker = Faker('en_US')
self.faker.seed(129) # contains 3 same points paid (5.9) self.faker.seed(129) # contains 3 same points paid (5.9)
self.test_daemon = get_test_daemon() self.test_daemon = get_test_daemon()

View file

@ -12,7 +12,7 @@ from lbrynet.p2p.RateLimiter import DummyRateLimiter
from lbrynet.extras.daemon import Downloader from lbrynet.extras.daemon import Downloader
from lbrynet.extras.daemon import ExchangeRateManager from lbrynet.extras.daemon import ExchangeRateManager
from lbrynet.extras.daemon.storage import SQLiteStorage from lbrynet.extras.daemon.storage import SQLiteStorage
from lbrynet.dht.peerfinder import DummyPeerFinder from lbrynet.extras.daemon.PeerFinder import DummyPeerFinder
from lbrynet.blob.EncryptedFileStatusReport import EncryptedFileStatusReport from lbrynet.blob.EncryptedFileStatusReport import EncryptedFileStatusReport
from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader from lbrynet.blob.EncryptedFileDownloader import ManagedEncryptedFileDownloader
from lbrynet.extras.wallet import LbryWalletManager from lbrynet.extras.wallet import LbryWalletManager

View file

@ -3,7 +3,7 @@ from lbrynet.extras.daemon import ExchangeRateManager
from lbrynet.p2p.Error import InvalidExchangeRateResponse from lbrynet.p2p.Error import InvalidExchangeRateResponse
from twisted.trial import unittest from twisted.trial import unittest
from twisted.internet import defer from twisted.internet import defer
from tests import util from tests import test_utils
from tests.mocks import ExchangeRateManager as DummyExchangeRateManager from tests.mocks import ExchangeRateManager as DummyExchangeRateManager
from tests.mocks import BTCLBCFeed, USDBTCFeed from tests.mocks import BTCLBCFeed, USDBTCFeed
@ -32,18 +32,18 @@ class FeeFormatTest(unittest.TestCase):
class ExchangeRateTest(unittest.TestCase): class ExchangeRateTest(unittest.TestCase):
def setUp(self): def setUp(self):
util.resetTime(self) test_utils.resetTime(self)
def test_invalid_rates(self): def test_invalid_rates(self):
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
ExchangeRateManager.ExchangeRate('USDBTC', 0, util.DEFAULT_ISO_TIME) ExchangeRateManager.ExchangeRate('USDBTC', 0, test_utils.DEFAULT_ISO_TIME)
with self.assertRaises(ValueError): with self.assertRaises(ValueError):
ExchangeRateManager.ExchangeRate('USDBTC', -1, util.DEFAULT_ISO_TIME) ExchangeRateManager.ExchangeRate('USDBTC', -1, test_utils.DEFAULT_ISO_TIME)
class FeeTest(unittest.TestCase): class FeeTest(unittest.TestCase):
def setUp(self): def setUp(self):
util.resetTime(self) test_utils.resetTime(self)
def test_fee_converts_to_lbc(self): def test_fee_converts_to_lbc(self):
fee = Fee({ fee = Fee({
@ -53,8 +53,8 @@ class FeeTest(unittest.TestCase):
}) })
rates = { rates = {
'BTCLBC': {'spot': 3.0, 'ts': util.DEFAULT_ISO_TIME + 1}, 'BTCLBC': {'spot': 3.0, 'ts': test_utils.DEFAULT_ISO_TIME + 1},
'USDBTC': {'spot': 2.0, 'ts': util.DEFAULT_ISO_TIME + 2} 'USDBTC': {'spot': 2.0, 'ts': test_utils.DEFAULT_ISO_TIME + 2}
} }
market_feeds = [BTCLBCFeed(), USDBTCFeed()] market_feeds = [BTCLBCFeed(), USDBTCFeed()]
@ -71,7 +71,7 @@ class FeeTest(unittest.TestCase):
}) })
rates = { rates = {
'BTCLBC': {'spot': 1.0, 'ts': util.DEFAULT_ISO_TIME + 1}, 'BTCLBC': {'spot': 1.0, 'ts': test_utils.DEFAULT_ISO_TIME + 1},
} }
market_feeds = [BTCLBCFeed()] market_feeds = [BTCLBCFeed()]
manager = DummyExchangeRateManager(market_feeds, rates) manager = DummyExchangeRateManager(market_feeds, rates)

View file

@ -1,4 +1,4 @@
import unittest from twisted.trial import unittest
from lbrynet.extras.daemon.Daemon import sort_claim_results from lbrynet.extras.daemon.Daemon import sort_claim_results

View file

@ -3,7 +3,7 @@ from io import StringIO
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.extras.cli import normalize_value, main from lbrynet.extras.cli import normalize_value, main
from lbrynet.p2p.system_info import get_platform from lbrynet.system_info import get_platform
class CLITest(unittest.TestCase): class CLITest(unittest.TestCase):

View file

@ -4,7 +4,7 @@ import sys
import tempfile import tempfile
from unittest import skipIf from unittest import skipIf
from twisted.trial import unittest from twisted.trial import unittest
from lbrynet.extras.daemon import conf from lbrynet import conf
from lbrynet.p2p.Error import InvalidCurrencyError from lbrynet.p2p.Error import InvalidCurrencyError