forked from LBRYCommunity/lbry-sdk
Merge branch 'master' into refactor-blob-requester
This commit is contained in:
commit
4727ee0403
47 changed files with 390 additions and 360 deletions
|
@ -1,6 +1,21 @@
|
|||
import logging
|
||||
|
||||
from lbrynet.analytics import utils
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def get_sd_hash(stream_info):
|
||||
if not stream_info:
|
||||
return None
|
||||
try:
|
||||
return stream_info['sources']['lbry_sd_hash']
|
||||
except (KeyError, TypeError, ValueError):
|
||||
log.debug('Failed to get sd_hash from %s', stream_info, exc_info=True)
|
||||
return None
|
||||
|
||||
|
||||
class Events(object):
|
||||
def __init__(self, context, lbry_id, session_id):
|
||||
self.context = context
|
||||
|
@ -19,6 +34,20 @@ class Events(object):
|
|||
'timestamp': utils.now()
|
||||
}
|
||||
|
||||
def download_started(self, name, stream_info=None):
|
||||
return {
|
||||
'userId': 'lbry',
|
||||
'event': 'Download Started',
|
||||
'properties': {
|
||||
'lbry_id': self.lbry_id,
|
||||
'session_id': self.session_id,
|
||||
'name': name,
|
||||
'stream_info': get_sd_hash(stream_info)
|
||||
},
|
||||
'context': self.context,
|
||||
'timestamp': utils.now()
|
||||
}
|
||||
|
||||
|
||||
def make_context(platform, wallet, is_dev=False):
|
||||
# TODO: distinguish between developer and release instances
|
||||
|
|
|
@ -7,12 +7,12 @@ from Crypto.Hash import SHA512
|
|||
from Crypto.PublicKey import RSA
|
||||
from lbrynet.core.client.ClientRequest import ClientRequest
|
||||
from lbrynet.core.Error import RequestCanceledError
|
||||
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, ILBRYWallet
|
||||
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, IWallet
|
||||
from lbrynet.pointtraderclient import pointtraderclient
|
||||
from twisted.internet import defer, threads
|
||||
from zope.interface import implements
|
||||
from twisted.python.failure import Failure
|
||||
from lbrynet.core.LBRYWallet import ReservedPoints
|
||||
from lbrynet.core.Wallet import ReservedPoints
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -21,7 +21,7 @@ log = logging.getLogger(__name__)
|
|||
class PTCWallet(object):
|
||||
"""This class sends payments to peers and also ensures that expected payments are received.
|
||||
This class is only intended to be used for testing."""
|
||||
implements(ILBRYWallet)
|
||||
implements(IWallet)
|
||||
|
||||
def __init__(self, db_dir):
|
||||
self.db_dir = db_dir
|
||||
|
|
|
@ -16,7 +16,7 @@ from twisted.internet import threads, defer
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYSession(object):
|
||||
class Session(object):
|
||||
"""This class manages all important services common to any application that uses the network:
|
||||
the hash announcer, which informs other peers that this peer is associated with some hash. Usually,
|
||||
this means this peer has a blob identified by the hash in question, but it can be used for other
|
||||
|
|
|
@ -17,15 +17,15 @@ from decimal import Decimal
|
|||
|
||||
from lbryum import SimpleConfig, Network
|
||||
from lbryum.lbrycrd import COIN
|
||||
from lbryum.wallet import WalletStorage, Wallet
|
||||
import lbryum.wallet
|
||||
from lbryum.commands import known_commands, Commands
|
||||
from lbryum.transaction import Transaction
|
||||
|
||||
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, ILBRYWallet
|
||||
from lbrynet.interfaces import IRequestCreator, IQueryHandlerFactory, IQueryHandler, IWallet
|
||||
from lbrynet.core.client.ClientRequest import ClientRequest
|
||||
from lbrynet.core.Error import UnknownNameError, InvalidStreamInfoError, RequestCanceledError
|
||||
from lbrynet.core.Error import InsufficientFundsError
|
||||
from lbrynet.metadata.LBRYMetadata import Metadata
|
||||
from lbrynet.metadata.Metadata import Metadata
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
alert = logging.getLogger("lbryalert." + __name__)
|
||||
|
@ -47,9 +47,9 @@ def _catch_connection_error(f):
|
|||
return w
|
||||
|
||||
|
||||
class LBRYWallet(object):
|
||||
"""This class implements the LBRYWallet interface for the LBRYcrd payment system"""
|
||||
implements(ILBRYWallet)
|
||||
class Wallet(object):
|
||||
"""This class implements the Wallet interface for the LBRYcrd payment system"""
|
||||
implements(IWallet)
|
||||
|
||||
_FIRST_RUN_UNKNOWN = 0
|
||||
_FIRST_RUN_YES = 1
|
||||
|
@ -762,9 +762,9 @@ class LBRYWallet(object):
|
|||
pass
|
||||
|
||||
|
||||
class LBRYcrdWallet(LBRYWallet):
|
||||
class LBRYcrdWallet(Wallet):
|
||||
def __init__(self, db_dir, wallet_dir=None, wallet_conf=None, lbrycrdd_path=None):
|
||||
LBRYWallet.__init__(self, db_dir)
|
||||
Wallet.__init__(self, db_dir)
|
||||
self.started_lbrycrdd = False
|
||||
self.wallet_dir = wallet_dir
|
||||
self.wallet_conf = wallet_conf
|
||||
|
@ -1108,10 +1108,10 @@ class LBRYcrdWallet(LBRYWallet):
|
|||
self.lbrycrdd.wait()
|
||||
|
||||
|
||||
class LBRYumWallet(LBRYWallet):
|
||||
class LBRYumWallet(Wallet):
|
||||
|
||||
def __init__(self, db_dir):
|
||||
LBRYWallet.__init__(self, db_dir)
|
||||
Wallet.__init__(self, db_dir)
|
||||
self.config = None
|
||||
self.network = None
|
||||
self.wallet = None
|
||||
|
@ -1189,8 +1189,8 @@ class LBRYumWallet(LBRYWallet):
|
|||
|
||||
def get_wallet():
|
||||
path = self.config.get_wallet_path()
|
||||
storage = WalletStorage(path)
|
||||
wallet = Wallet(storage)
|
||||
storage = lbryum.wallet.WalletStorage(path)
|
||||
wallet = lbryum.wallet.Wallet(storage)
|
||||
if not storage.file_exists:
|
||||
self.first_run = True
|
||||
seed = wallet.make_seed()
|
|
@ -93,7 +93,6 @@ class DummyBlobHandler(object):
|
|||
|
||||
|
||||
class StandaloneBlobDownloader(object):
|
||||
|
||||
def __init__(self, blob_hash, blob_manager, peer_finder, rate_limiter, payment_rate_manager, wallet):
|
||||
self.blob_hash = blob_hash
|
||||
self.blob_manager = blob_manager
|
||||
|
@ -142,4 +141,4 @@ class StandaloneBlobDownloader(object):
|
|||
def insufficient_funds(self, err):
|
||||
self.stop()
|
||||
if not self.finished_deferred.called:
|
||||
self.finished_deferred.errback(err)
|
||||
self.finished_deferred.errback(err)
|
||||
|
|
|
@ -81,7 +81,7 @@ def disable_noisy_loggers():
|
|||
logging.getLogger('lbrynet.core.server').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.dht').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.lbrynet_daemon').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.core.LBRYWallet').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.core.Wallet').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.lbryfile').setLevel(logging.INFO)
|
||||
logging.getLogger('lbrynet.lbryfilemanager').setLevel(logging.INFO)
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ class CryptStreamDownloader(object):
|
|||
|
||||
@param payment_rate_manager: A PaymentRateManager object
|
||||
|
||||
@param wallet: An object which implements the ILBRYWallet interface
|
||||
@param wallet: An object which implements the IWallet interface
|
||||
|
||||
@return:
|
||||
"""
|
||||
|
|
|
@ -233,14 +233,14 @@
|
|||
# " foreign key(stream_hash) references lbry_files(stream_hash)" +
|
||||
# ")")
|
||||
# new_db.commit()
|
||||
# LBRYFILE_STATUS = "t"
|
||||
# LBRYFILE_OPTIONS = "o"
|
||||
# FILE_STATUS = "t"
|
||||
# FILE_OPTIONS = "o"
|
||||
# c = new_db.cursor()
|
||||
# for k, v in old_db.RangeIter():
|
||||
# key_type, stream_hash = json.loads(k)
|
||||
# if key_type == LBRYFILE_STATUS:
|
||||
# if key_type == FILE_STATUS:
|
||||
# try:
|
||||
# rate = json.loads(old_db.Get(json.dumps((LBRYFILE_OPTIONS, stream_hash))))[0]
|
||||
# rate = json.loads(old_db.Get(json.dumps((FILE_OPTIONS, stream_hash))))[0]
|
||||
# except KeyError:
|
||||
# rate = None
|
||||
# c.execute("insert into lbry_file_options values (?, ?, ?)",
|
||||
|
|
|
@ -548,13 +548,13 @@ class IStreamDescriptorValidator(Interface):
|
|||
"""
|
||||
|
||||
|
||||
class ILBRYWallet(Interface):
|
||||
class IWallet(Interface):
|
||||
"""
|
||||
Send and receive payments.
|
||||
|
||||
To send a payment, a payment reservation must be obtained first. This guarantees that a payment
|
||||
isn't promised if it can't be paid. When the service in question is rendered, the payment
|
||||
reservation must be given to the ILBRYWallet along with the final price. The reservation can also
|
||||
reservation must be given to the IWallet along with the final price. The reservation can also
|
||||
be canceled.
|
||||
"""
|
||||
def stop(self):
|
||||
|
|
|
@ -11,7 +11,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class DBLBRYFileMetadataManager(object):
|
||||
class DBEncryptedFileMetadataManager(object):
|
||||
"""Store and provide access to LBRY file metadata using sqlite"""
|
||||
|
||||
def __init__(self, db_dir):
|
||||
|
@ -243,7 +243,7 @@ class DBLBRYFileMetadataManager(object):
|
|||
return d
|
||||
|
||||
|
||||
class TempLBRYFileMetadataManager(object):
|
||||
class TempEncryptedFileMetadataManager(object):
|
||||
def __init__(self):
|
||||
self.streams = {}
|
||||
self.stream_blobs = {}
|
|
@ -11,7 +11,7 @@ import os
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
LBRYFileStreamType = "lbryfile"
|
||||
EncryptedFileStreamType = "lbryfile"
|
||||
|
||||
|
||||
def save_sd_info(stream_info_manager, sd_info, ignore_duplicate=False):
|
||||
|
@ -50,7 +50,7 @@ def get_sd_info(stream_info_manager, stream_hash, include_blobs):
|
|||
|
||||
def format_info(stream_info):
|
||||
fields = {}
|
||||
fields['stream_type'] = LBRYFileStreamType
|
||||
fields['stream_type'] = EncryptedFileStreamType
|
||||
fields['stream_name'] = stream_info[1]
|
||||
fields['key'] = stream_info[0]
|
||||
fields['suggested_file_name'] = stream_info[2]
|
||||
|
@ -121,7 +121,7 @@ def create_plain_sd(stream_info_manager, stream_hash, file_name, overwrite_exist
|
|||
return d
|
||||
|
||||
|
||||
class LBRYFileStreamDescriptorValidator(object):
|
||||
class EncryptedFileStreamDescriptorValidator(object):
|
||||
def __init__(self, raw_info):
|
||||
self.raw_info = raw_info
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ from lbrynet.cryptstream.client.CryptStreamDownloader import CryptStreamDownload
|
|||
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
||||
from lbrynet.core.StreamDescriptor import StreamMetadata
|
||||
from lbrynet.interfaces import IStreamDownloaderFactory
|
||||
from lbrynet.lbryfile.client.LBRYFileMetadataHandler import LBRYFileMetadataHandler
|
||||
from lbrynet.lbryfile.client.EncryptedFileMetadataHandler import EncryptedFileMetadataHandler
|
||||
import os
|
||||
from twisted.internet import defer, threads, reactor
|
||||
from twisted.python.procutils import which
|
||||
|
@ -19,7 +19,7 @@ import traceback
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYFileDownloader(CryptStreamDownloader):
|
||||
class EncryptedFileDownloader(CryptStreamDownloader):
|
||||
"""Classes which inherit from this class download LBRY files"""
|
||||
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
|
@ -120,10 +120,10 @@ class LBRYFileDownloader(CryptStreamDownloader):
|
|||
return 0
|
||||
|
||||
def _get_metadata_handler(self, download_manager):
|
||||
return LBRYFileMetadataHandler(self.stream_hash, self.stream_info_manager, download_manager)
|
||||
return EncryptedFileMetadataHandler(self.stream_hash, self.stream_info_manager, download_manager)
|
||||
|
||||
|
||||
class LBRYFileDownloaderFactory(object):
|
||||
class EncryptedFileDownloaderFactory(object):
|
||||
implements(IStreamDownloaderFactory)
|
||||
|
||||
def __init__(self, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
|
@ -165,10 +165,10 @@ class LBRYFileDownloaderFactory(object):
|
|||
pass
|
||||
|
||||
|
||||
class LBRYFileSaver(LBRYFileDownloader):
|
||||
class EncryptedFileSaver(EncryptedFileDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet, download_directory, upload_allowed, file_name=None):
|
||||
LBRYFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
stream_info_manager, payment_rate_manager, wallet, upload_allowed)
|
||||
self.download_directory = download_directory
|
||||
self.file_name = file_name
|
||||
|
@ -182,7 +182,7 @@ class LBRYFileSaver(LBRYFileDownloader):
|
|||
return str(self.file_name)
|
||||
|
||||
def set_stream_info(self):
|
||||
d = LBRYFileDownloader.set_stream_info(self)
|
||||
d = EncryptedFileDownloader.set_stream_info(self)
|
||||
|
||||
def set_file_name():
|
||||
if self.file_name is None:
|
||||
|
@ -195,7 +195,7 @@ class LBRYFileSaver(LBRYFileDownloader):
|
|||
return d
|
||||
|
||||
def stop(self, err=None):
|
||||
d = LBRYFileDownloader.stop(self, err=err)
|
||||
d = EncryptedFileDownloader.stop(self, err=err)
|
||||
d.addCallback(lambda _: self._delete_from_info_manager())
|
||||
return d
|
||||
|
||||
|
@ -257,15 +257,15 @@ class LBRYFileSaver(LBRYFileDownloader):
|
|||
return self.stream_info_manager.delete_stream(self.stream_hash)
|
||||
|
||||
|
||||
class LBRYFileSaverFactory(LBRYFileDownloaderFactory):
|
||||
class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory):
|
||||
def __init__(self, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
wallet, download_directory):
|
||||
LBRYFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager,
|
||||
EncryptedFileDownloaderFactory.__init__(self, peer_finder, rate_limiter, blob_manager,
|
||||
stream_info_manager, wallet)
|
||||
self.download_directory = download_directory
|
||||
|
||||
def _make_downloader(self, stream_hash, payment_rate_manager, stream_info, upload_allowed):
|
||||
return LBRYFileSaver(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager,
|
||||
return EncryptedFileSaver(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager,
|
||||
self.stream_info_manager, payment_rate_manager, self.wallet,
|
||||
self.download_directory, upload_allowed)
|
||||
|
||||
|
@ -274,16 +274,16 @@ class LBRYFileSaverFactory(LBRYFileDownloaderFactory):
|
|||
return "Save"
|
||||
|
||||
|
||||
class LBRYFileOpener(LBRYFileDownloader):
|
||||
class EncryptedFileOpener(EncryptedFileDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet, upload_allowed):
|
||||
LBRYFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
EncryptedFileDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
stream_info_manager, payment_rate_manager, wallet, upload_allowed)
|
||||
self.process = None
|
||||
self.process_log = None
|
||||
|
||||
def stop(self, err=None):
|
||||
d = LBRYFileDownloader.stop(self, err=err)
|
||||
d = EncryptedFileDownloader.stop(self, err=err)
|
||||
d.addCallback(lambda _: self._delete_from_info_manager())
|
||||
return d
|
||||
|
||||
|
@ -333,7 +333,7 @@ class LBRYFileOpener(LBRYFileDownloader):
|
|||
return self.stream_info_manager.delete_stream(self.stream_hash)
|
||||
|
||||
|
||||
class LBRYFileOpenerFactory(LBRYFileDownloaderFactory):
|
||||
class EncryptedFileOpenerFactory(EncryptedFileDownloaderFactory):
|
||||
def can_download(self, sd_validator):
|
||||
if which('vlc'):
|
||||
return True
|
||||
|
@ -346,7 +346,7 @@ class LBRYFileOpenerFactory(LBRYFileDownloaderFactory):
|
|||
return False
|
||||
|
||||
def _make_downloader(self, stream_hash, payment_rate_manager, stream_info, upload_allowed):
|
||||
return LBRYFileOpener(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager,
|
||||
return EncryptedFileOpener(stream_hash, self.peer_finder, self.rate_limiter, self.blob_manager,
|
||||
self.stream_info_manager, payment_rate_manager, self.wallet, upload_allowed)
|
||||
|
||||
@staticmethod
|
|
@ -7,7 +7,7 @@ from lbrynet.interfaces import IMetadataHandler
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYFileMetadataHandler(object):
|
||||
class EncryptedFileMetadataHandler(object):
|
||||
implements(IMetadataHandler)
|
||||
|
||||
def __init__(self, stream_hash, stream_info_manager, download_manager):
|
|
@ -1,12 +1,12 @@
|
|||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType, LBRYFileStreamDescriptorValidator
|
||||
from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator
|
||||
from lbrynet.core.DownloadOption import DownloadOption, DownloadOptionChoice
|
||||
|
||||
|
||||
def add_lbry_file_to_sd_identifier(sd_identifier):
|
||||
sd_identifier.add_stream_type(LBRYFileStreamType, LBRYFileStreamDescriptorValidator, LBRYFileOptions())
|
||||
sd_identifier.add_stream_type(EncryptedFileStreamType, EncryptedFileStreamDescriptorValidator, EncryptedFileOptions())
|
||||
|
||||
|
||||
class LBRYFileOptions(object):
|
||||
class EncryptedFileOptions(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
|
@ -16,9 +16,9 @@ from twisted.protocols.basic import FileSender
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYFileStreamCreator(CryptStreamCreator):
|
||||
class EncryptedFileStreamCreator(CryptStreamCreator):
|
||||
"""
|
||||
A CryptStreamCreator which adds itself and its additional metadata to an LBRYFileManager
|
||||
A CryptStreamCreator which adds itself and its additional metadata to an EncryptedFileManager
|
||||
"""
|
||||
def __init__(self, blob_manager, lbry_file_manager, name=None,
|
||||
key=None, iv_generator=None, suggested_file_name=None):
|
||||
|
@ -93,11 +93,11 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non
|
|||
into chunks and encrypted, and then a stream descriptor file with the stream parameters
|
||||
and other metadata is written to disk.
|
||||
|
||||
@param session: An LBRYSession object.
|
||||
@type session: LBRYSession
|
||||
@param session: An Session object.
|
||||
@type session: Session
|
||||
|
||||
@param lbry_file_manager: The LBRYFileManager object this LBRY File will be added to.
|
||||
@type lbry_file_manager: LBRYFileManager
|
||||
@param lbry_file_manager: The EncryptedFileManager object this LBRY File will be added to.
|
||||
@type lbry_file_manager: EncryptedFileManager
|
||||
|
||||
@param file_name: The path to the plain file.
|
||||
@type file_name: string
|
||||
|
@ -141,7 +141,7 @@ def create_lbry_file(session, lbry_file_manager, file_name, file_handle, key=Non
|
|||
|
||||
base_file_name = os.path.basename(file_name)
|
||||
|
||||
lbry_file_creator = LBRYFileStreamCreator(session.blob_manager, lbry_file_manager, base_file_name,
|
||||
lbry_file_creator = EncryptedFileStreamCreator(session.blob_manager, lbry_file_manager, base_file_name,
|
||||
key, iv_generator, suggested_file_name)
|
||||
|
||||
def start_stream():
|
|
@ -5,8 +5,8 @@ Download LBRY Files from LBRYnet and save them to disk.
|
|||
from zope.interface import implements
|
||||
from lbrynet.core.client.StreamProgressManager import FullStreamProgressManager
|
||||
from lbrynet.core.StreamDescriptor import StreamMetadata
|
||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaver, LBRYFileDownloader
|
||||
from lbrynet.lbryfilemanager.LBRYFileStatusReport import LBRYFileStatusReport
|
||||
from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaver, EncryptedFileDownloader
|
||||
from lbrynet.lbryfilemanager.EncryptedFileStatusReport import EncryptedFileStatusReport
|
||||
from lbrynet.interfaces import IStreamDownloaderFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import save_sd_info
|
||||
from twisted.internet import defer
|
||||
|
@ -15,7 +15,7 @@ import logging
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ManagedLBRYFileDownloader(LBRYFileSaver):
|
||||
class ManagedEncryptedFileDownloader(EncryptedFileSaver):
|
||||
|
||||
STATUS_RUNNING = "running"
|
||||
STATUS_STOPPED = "stopped"
|
||||
|
@ -24,7 +24,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
def __init__(self, rowid, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
lbry_file_manager, payment_rate_manager, wallet, download_directory, upload_allowed,
|
||||
file_name=None):
|
||||
LBRYFileSaver.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
EncryptedFileSaver.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
stream_info_manager, payment_rate_manager, wallet, download_directory,
|
||||
upload_allowed, file_name)
|
||||
self.sd_hash = None
|
||||
|
@ -68,11 +68,11 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
d.addCallback(lambda _: self.lbry_file_manager.get_lbry_file_status(self))
|
||||
|
||||
def restore_status(status):
|
||||
if status == ManagedLBRYFileDownloader.STATUS_RUNNING:
|
||||
if status == ManagedEncryptedFileDownloader.STATUS_RUNNING:
|
||||
return self.start()
|
||||
elif status == ManagedLBRYFileDownloader.STATUS_STOPPED:
|
||||
elif status == ManagedEncryptedFileDownloader.STATUS_STOPPED:
|
||||
return defer.succeed(False)
|
||||
elif status == ManagedLBRYFileDownloader.STATUS_FINISHED:
|
||||
elif status == ManagedEncryptedFileDownloader.STATUS_FINISHED:
|
||||
self.completed = True
|
||||
return defer.succeed(True)
|
||||
|
||||
|
@ -84,7 +84,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
def set_saving_status_done():
|
||||
self.saving_status = False
|
||||
|
||||
d = LBRYFileDownloader.stop(self, err=err) # LBRYFileSaver deletes metadata when it's stopped. We don't want that here.
|
||||
d = EncryptedFileDownloader.stop(self, err=err) # EncryptedFileSaver deletes metadata when it's stopped. We don't want that here.
|
||||
if change_status is True:
|
||||
self.saving_status = True
|
||||
d.addCallback(lambda _: self._save_status())
|
||||
|
@ -111,7 +111,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
s = "stopped"
|
||||
else:
|
||||
s = "running"
|
||||
status = LBRYFileStatusReport(self.file_name, num_completed, num_known, s)
|
||||
status = EncryptedFileStatusReport(self.file_name, num_completed, num_known, s)
|
||||
return status
|
||||
|
||||
d = self.stream_info_manager.get_blobs_for_stream(self.stream_hash)
|
||||
|
@ -121,7 +121,7 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
|
||||
def _start(self):
|
||||
|
||||
d = LBRYFileSaver._start(self)
|
||||
d = EncryptedFileSaver._start(self)
|
||||
|
||||
d.addCallback(lambda _: self.stream_info_manager._get_sd_blob_hashes_for_stream(self.stream_hash))
|
||||
|
||||
|
@ -153,18 +153,18 @@ class ManagedLBRYFileDownloader(LBRYFileSaver):
|
|||
|
||||
def _save_status(self):
|
||||
if self.completed is True:
|
||||
s = ManagedLBRYFileDownloader.STATUS_FINISHED
|
||||
s = ManagedEncryptedFileDownloader.STATUS_FINISHED
|
||||
elif self.stopped is True:
|
||||
s = ManagedLBRYFileDownloader.STATUS_STOPPED
|
||||
s = ManagedEncryptedFileDownloader.STATUS_STOPPED
|
||||
else:
|
||||
s = ManagedLBRYFileDownloader.STATUS_RUNNING
|
||||
s = ManagedEncryptedFileDownloader.STATUS_RUNNING
|
||||
return self.lbry_file_manager.change_lbry_file_status(self, s)
|
||||
|
||||
def _get_progress_manager(self, download_manager):
|
||||
return FullStreamProgressManager(self._finished_downloading, self.blob_manager, download_manager)
|
||||
|
||||
|
||||
class ManagedLBRYFileDownloaderFactory(object):
|
||||
class ManagedEncryptedFileDownloaderFactory(object):
|
||||
implements(IStreamDownloaderFactory)
|
||||
|
||||
def __init__(self, lbry_file_manager):
|
|
@ -9,9 +9,9 @@ from twisted.enterprise import adbapi
|
|||
from twisted.internet import defer, task, reactor
|
||||
from twisted.python.failure import Failure
|
||||
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
||||
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.cryptstream.client.CryptStreamDownloader import AlreadyStoppedError, CurrentlyStoppingError
|
||||
from lbrynet.core.sqlite_helpers import rerun_if_locked
|
||||
|
@ -20,7 +20,7 @@ from lbrynet.core.sqlite_helpers import rerun_if_locked
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYFileManager(object):
|
||||
class EncryptedFileManager(object):
|
||||
"""
|
||||
Keeps track of currently opened LBRY Files, their options, and their LBRY File specific metadata.
|
||||
"""
|
||||
|
@ -35,7 +35,7 @@ class LBRYFileManager(object):
|
|||
self.download_directory = download_directory
|
||||
else:
|
||||
self.download_directory = os.getcwd()
|
||||
log.debug("Download directory for LBRYFileManager: %s", str(self.download_directory))
|
||||
log.debug("Download directory for EncryptedFileManager: %s", str(self.download_directory))
|
||||
|
||||
def setup(self):
|
||||
d = self._open_db()
|
||||
|
@ -68,8 +68,8 @@ class LBRYFileManager(object):
|
|||
return dl
|
||||
|
||||
def _add_to_sd_identifier(self):
|
||||
downloader_factory = ManagedLBRYFileDownloaderFactory(self)
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory)
|
||||
downloader_factory = ManagedEncryptedFileDownloaderFactory(self)
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory)
|
||||
|
||||
def _start_lbry_files(self):
|
||||
|
||||
|
@ -101,7 +101,7 @@ class LBRYFileManager(object):
|
|||
if not download_directory:
|
||||
download_directory = self.download_directory
|
||||
payment_rate_manager.min_blob_data_payment_rate = blob_data_rate
|
||||
lbry_file_downloader = ManagedLBRYFileDownloader(rowid, stream_hash,
|
||||
lbry_file_downloader = ManagedEncryptedFileDownloader(rowid, stream_hash,
|
||||
self.session.peer_finder,
|
||||
self.session.rate_limiter,
|
||||
self.session.blob_manager,
|
||||
|
@ -207,7 +207,7 @@ class LBRYFileManager(object):
|
|||
def _save_lbry_file(self, stream_hash, data_payment_rate):
|
||||
def do_save(db_transaction):
|
||||
db_transaction.execute("insert into lbry_file_options values (?, ?, ?)",
|
||||
(data_payment_rate, ManagedLBRYFileDownloader.STATUS_STOPPED,
|
||||
(data_payment_rate, ManagedEncryptedFileDownloader.STATUS_STOPPED,
|
||||
stream_hash))
|
||||
return db_transaction.lastrowid
|
||||
return self.sql_db.runInteraction(do_save)
|
||||
|
@ -236,7 +236,7 @@ class LBRYFileManager(object):
|
|||
def _get_lbry_file_status(self, rowid):
|
||||
d = self.sql_db.runQuery("select status from lbry_file_options where rowid = ?",
|
||||
(rowid,))
|
||||
d.addCallback(lambda r: r[0][0] if len(r) else ManagedLBRYFileDownloader.STATUS_STOPPED)
|
||||
d.addCallback(lambda r: r[0][0] if len(r) else ManagedEncryptedFileDownloader.STATUS_STOPPED)
|
||||
return d
|
||||
|
||||
@rerun_if_locked
|
|
@ -1,4 +1,4 @@
|
|||
class LBRYFileStatusReport(object):
|
||||
class EncryptedFileStatusReport(object):
|
||||
def __init__(self, name, num_completed, num_known, running_status):
|
||||
self.name = name
|
||||
self.num_completed = num_completed
|
|
@ -5,7 +5,7 @@ import logging
|
|||
import sys
|
||||
from lbrynet.lbrylive.LiveStreamCreator import StdOutLiveStreamCreator
|
||||
from lbrynet.core.BlobManager import TempBlobManager
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerFactory
|
||||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
||||
|
@ -16,7 +16,7 @@ from lbrynet.dht.node import Node
|
|||
from twisted.internet import defer, task
|
||||
|
||||
|
||||
class LBRYStdinUploader():
|
||||
class StdinUploader():
|
||||
"""This class reads from standard in, creates a stream, and makes it available on the network."""
|
||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager, blob_manager_class=TempBlobManager):
|
||||
|
@ -29,7 +29,7 @@ class LBRYStdinUploader():
|
|||
"""
|
||||
self.peer_port = peer_port
|
||||
self.lbry_server_port = None
|
||||
self.session = LBRYSession(blob_manager_class=blob_manager_class,
|
||||
self.session = Session(blob_manager_class=blob_manager_class,
|
||||
stream_info_manager_class=stream_info_manager_class,
|
||||
dht_node_class=Node, dht_node_port=dht_node_port,
|
||||
known_dht_nodes=known_dht_nodes, peer_port=self.peer_port,
|
||||
|
@ -99,9 +99,9 @@ def launch_stdin_uploader():
|
|||
|
||||
logging.basicConfig(level=logging.WARNING, filename="ul.log")
|
||||
if len(sys.argv) == 4:
|
||||
uploader = LBRYStdinUploader(int(sys.argv[2]), int(sys.argv[3]), [])
|
||||
uploader = StdinUploader(int(sys.argv[2]), int(sys.argv[3]), [])
|
||||
elif len(sys.argv) == 6:
|
||||
uploader = LBRYStdinUploader(int(sys.argv[2]), int(sys.argv[3]), [(sys.argv[4], int(sys.argv[5]))])
|
||||
uploader = StdinUploader(int(sys.argv[2]), int(sys.argv[3]), [(sys.argv[4], int(sys.argv[5]))])
|
||||
else:
|
||||
print "Usage: lbrynet-stdin-uploader <stream_name> <peer_port> <dht_node_port>" \
|
||||
" [<dht_bootstrap_host> <dht_bootstrap port>]"
|
|
@ -4,9 +4,9 @@
|
|||
import logging
|
||||
import sys
|
||||
|
||||
from lbrynet.lbrylive.client.LiveStreamDownloader import LBRYLiveStreamDownloader
|
||||
from lbrynet.lbrylive.client.LiveStreamDownloader import LiveStreamDownloader
|
||||
from lbrynet.core.BlobManager import TempBlobManager
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader
|
||||
from lbrynet.core.StreamDescriptor import BlobStreamDescriptorReader
|
||||
from lbrynet.lbrylive.PaymentRateManager import BaseLiveStreamPaymentRateManager
|
||||
|
@ -16,7 +16,7 @@ from lbrynet.dht.node import Node
|
|||
from twisted.internet import task
|
||||
|
||||
|
||||
class LBRYStdoutDownloader():
|
||||
class StdoutDownloader():
|
||||
"""This class downloads a live stream from the network and outputs it to standard out."""
|
||||
def __init__(self, dht_node_port, known_dht_nodes,
|
||||
stream_info_manager_class=DBLiveStreamMetadataManager, blob_manager_class=TempBlobManager):
|
||||
|
@ -27,7 +27,7 @@ class LBRYStdoutDownloader():
|
|||
|
||||
"""
|
||||
|
||||
self.session = LBRYSession(blob_manager_class=blob_manager_class,
|
||||
self.session = Session(blob_manager_class=blob_manager_class,
|
||||
stream_info_manager_class=stream_info_manager_class,
|
||||
dht_node_class=Node, dht_node_port=dht_node_port, known_dht_nodes=known_dht_nodes,
|
||||
use_upnp=False)
|
||||
|
@ -55,7 +55,7 @@ class LBRYStdoutDownloader():
|
|||
d.addCallbacks(self.read_sd_file)
|
||||
|
||||
def start_stream(stream_hash):
|
||||
consumer = LBRYLiveStreamDownloader(stream_hash, self.session.peer_finder,
|
||||
consumer = LiveStreamDownloader(stream_hash, self.session.peer_finder,
|
||||
self.session.rate_limiter, self.session.blob_manager,
|
||||
self.stream_info_manager, self.payment_rate_manager,
|
||||
self.session.wallet)
|
||||
|
@ -76,9 +76,9 @@ def launch_stdout_downloader():
|
|||
|
||||
logging.basicConfig(level=logging.WARNING, filename="dl.log")
|
||||
if len(sys.argv) == 3:
|
||||
downloader = LBRYStdoutDownloader(int(sys.argv[2]), [])
|
||||
downloader = StdoutDownloader(int(sys.argv[2]), [])
|
||||
elif len(sys.argv) == 5:
|
||||
downloader = LBRYStdoutDownloader(int(sys.argv[2]), [(sys.argv[3], int(sys.argv[4]))])
|
||||
downloader = StdoutDownloader(int(sys.argv[2]), [(sys.argv[3], int(sys.argv[4]))])
|
||||
else:
|
||||
print "Usage: lbrynet-stdout-downloader <sd_hash> <peer_port> <dht_node_port>" \
|
||||
" [<dht_bootstrap_host> <dht_bootstrap port>]"
|
|
@ -84,7 +84,7 @@ def get_sd_info(stream_info_manager, stream_hash, include_blobs):
|
|||
return d
|
||||
|
||||
|
||||
class LBRYLiveStreamDescriptorValidator(object):
|
||||
class LiveStreamDescriptorValidator(object):
|
||||
implements(IStreamDescriptorValidator)
|
||||
|
||||
def __init__(self, raw_info):
|
||||
|
|
|
@ -12,7 +12,7 @@ from lbrynet.interfaces import IStreamDownloaderFactory
|
|||
from lbrynet.lbrylive.StreamDescriptor import LiveStreamType
|
||||
|
||||
|
||||
class LiveStreamDownloader(CryptStreamDownloader):
|
||||
class _LiveStreamDownloader(CryptStreamDownloader):
|
||||
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet, upload_allowed):
|
||||
|
@ -39,10 +39,10 @@ class LiveStreamDownloader(CryptStreamDownloader):
|
|||
return defer.succeed(True)
|
||||
|
||||
|
||||
class LBRYLiveStreamDownloader(LiveStreamDownloader):
|
||||
class LiveStreamDownloader(_LiveStreamDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet, upload_allowed):
|
||||
LiveStreamDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
_LiveStreamDownloader.__init__(self, stream_hash, peer_finder, rate_limiter, blob_manager,
|
||||
stream_info_manager, payment_rate_manager, wallet, upload_allowed)
|
||||
|
||||
#self.writer = process.ProcessWriter(reactor, self, 'write', 1)
|
||||
|
@ -65,17 +65,17 @@ class LBRYLiveStreamDownloader(LiveStreamDownloader):
|
|||
return write_func
|
||||
|
||||
|
||||
class FullLiveStreamDownloader(LiveStreamDownloader):
|
||||
class FullLiveStreamDownloader(_LiveStreamDownloader):
|
||||
def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager,
|
||||
payment_rate_manager, wallet, upload_allowed):
|
||||
LiveStreamDownloader.__init__(self, stream_hash, peer_finder, rate_limiter,
|
||||
_LiveStreamDownloader.__init__(self, stream_hash, peer_finder, rate_limiter,
|
||||
blob_manager, stream_info_manager, payment_rate_manager,
|
||||
wallet, upload_allowed)
|
||||
self.file_handle = None
|
||||
self.file_name = None
|
||||
|
||||
def set_stream_info(self):
|
||||
d = LiveStreamDownloader.set_stream_info(self)
|
||||
d = _LiveStreamDownloader.set_stream_info(self)
|
||||
|
||||
def set_file_name_if_unset():
|
||||
if not self.file_name:
|
||||
|
@ -88,7 +88,7 @@ class FullLiveStreamDownloader(LiveStreamDownloader):
|
|||
|
||||
def stop(self, err=None):
|
||||
d = self._close_file()
|
||||
d.addBoth(lambda _: LiveStreamDownloader.stop(self, err))
|
||||
d.addBoth(lambda _: _LiveStreamDownloader.stop(self, err))
|
||||
return d
|
||||
|
||||
def _start(self):
|
||||
|
@ -96,7 +96,7 @@ class FullLiveStreamDownloader(LiveStreamDownloader):
|
|||
d = self._open_file()
|
||||
else:
|
||||
d = defer.succeed(True)
|
||||
d.addCallback(lambda _: LiveStreamDownloader._start(self))
|
||||
d.addCallback(lambda _: _LiveStreamDownloader._start(self))
|
||||
return d
|
||||
|
||||
def _open_file(self):
|
||||
|
@ -179,4 +179,4 @@ def add_full_live_stream_downloader_to_sd_identifier(session, stream_info_manage
|
|||
stream_info_manager,
|
||||
session.wallet,
|
||||
base_live_stream_payment_rate_manager)
|
||||
sd_identifier.add_stream_downloader_factory(LiveStreamType, downloader_factory)
|
||||
sd_identifier.add_stream_downloader_factory(LiveStreamType, downloader_factory)
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from lbrynet.lbrylive.StreamDescriptor import LiveStreamType, LBRYLiveStreamDescriptorValidator
|
||||
from lbrynet.lbrylive.StreamDescriptor import LiveStreamType, LiveStreamDescriptorValidator
|
||||
from lbrynet.core.DownloadOption import DownloadOption, DownloadOptionChoice
|
||||
|
||||
|
||||
def add_live_stream_to_sd_identifier(sd_identifier, base_live_stream_payment_rate_manager):
|
||||
sd_identifier.add_stream_type(LiveStreamType, LBRYLiveStreamDescriptorValidator,
|
||||
sd_identifier.add_stream_type(LiveStreamType, LiveStreamDescriptorValidator,
|
||||
LiveStreamOptions(base_live_stream_payment_rate_manager))
|
||||
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@ from yapsy.PluginManager import PluginManager
|
|||
from twisted.internet import defer, threads, stdio, task, error
|
||||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.lbrynet_console.ConsoleControl import ConsoleControl
|
||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||
from lbrynet.lbrynet_console.Settings import Settings
|
||||
from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager
|
||||
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, API_CONNECTION_STRING # , MIN_BLOB_INFO_PAYMENT_RATE
|
||||
from lbrynet.core.utils import generate_id
|
||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier
|
||||
|
@ -24,33 +24,33 @@ from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerF
|
|||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
||||
from lbrynet.core.PTCWallet import PTCWallet
|
||||
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileOpenerFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||
from lbrynet.lbryfile.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileOpenerFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType
|
||||
from lbrynet.lbryfile.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager, TempEncryptedFileMetadataManager
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ApplicationStatusFactory, GetWalletBalancesFactory, ShutDownFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ImmediateAnnounceAllBlobsFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import LBRYFileStatusFactory, DeleteLBRYFileChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ToggleLBRYFileRunningChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import EncryptedFileStatusFactory, DeleteEncryptedFileChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ToggleEncryptedFileRunningChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ModifyApplicationDefaultsFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import CreateLBRYFileFactory, PublishStreamDescriptorChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import CreateEncryptedFileFactory, PublishStreamDescriptorChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ShowPublishedSDHashesChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import CreatePlainStreamDescriptorChooserFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ShowLBRYFileStreamHashChooserFactory, AddStreamFromHashFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ShowEncryptedFileStreamHashChooserFactory, AddStreamFromHashFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import AddStreamFromSDFactory, AddStreamFromLBRYcrdNameFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ClaimNameFactory, GetNewWalletAddressFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ShowServerStatusFactory, ModifyServerSettingsFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ModifyLBRYFileOptionsChooserFactory, StatusFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import ModifyEncryptedFileOptionsChooserFactory, StatusFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import PeerStatsAndSettingsChooserFactory, PublishFactory
|
||||
from lbrynet.lbrynet_console.ControlHandlers import BlockchainStatusFactory
|
||||
from lbrynet.core.LBRYWallet import LBRYcrdWallet, LBRYumWallet
|
||||
from lbrynet.core.Wallet import LBRYcrdWallet, LBRYumWallet
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
alert = logging.getLogger("lbryalert." + __name__)
|
||||
|
||||
|
||||
class LBRYConsole():
|
||||
class Console():
|
||||
"""A class which can upload and download file streams to and from the network"""
|
||||
def __init__(self, peer_port, dht_node_port, known_dht_nodes, fake_wallet,
|
||||
lbrycrd_conf, lbrycrd_dir, use_upnp, data_dir, created_data_dir,
|
||||
|
@ -93,7 +93,7 @@ class LBRYConsole():
|
|||
self.command_handlers = []
|
||||
self.query_handlers = {}
|
||||
|
||||
self.settings = LBRYSettings(self.db_dir)
|
||||
self.settings = Settings(self.db_dir)
|
||||
self.blob_request_payment_rate_manager = None
|
||||
self.lbryid = None
|
||||
self.sd_identifier = StreamDescriptorIdentifier()
|
||||
|
@ -239,7 +239,7 @@ class LBRYConsole():
|
|||
|
||||
alert.info("Databases loaded.")
|
||||
|
||||
self.session = LBRYSession(results['default_data_payment_rate'], db_dir=self.db_dir, lbryid=self.lbryid,
|
||||
self.session = Session(results['default_data_payment_rate'], db_dir=self.db_dir, lbryid=self.lbryid,
|
||||
blob_dir=self.blobfile_dir, dht_node_port=self.dht_node_port,
|
||||
known_dht_nodes=self.known_dht_nodes, peer_port=self.peer_port,
|
||||
use_upnp=self.use_upnp, wallet=results['wallet'])
|
||||
|
@ -297,11 +297,11 @@ class LBRYConsole():
|
|||
"catch up with our blockchain.\n", points_string)
|
||||
|
||||
def _setup_lbry_file_manager(self):
|
||||
self.lbry_file_metadata_manager = DBLBRYFileMetadataManager(self.db_dir)
|
||||
self.lbry_file_metadata_manager = DBEncryptedFileMetadataManager(self.db_dir)
|
||||
d = self.lbry_file_metadata_manager.setup()
|
||||
|
||||
def set_lbry_file_manager():
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.lbry_file_metadata_manager, self.sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.lbry_file_metadata_manager, self.sd_identifier)
|
||||
return self.lbry_file_manager.setup()
|
||||
|
||||
d.addCallback(lambda _: set_lbry_file_manager())
|
||||
|
@ -309,11 +309,11 @@ class LBRYConsole():
|
|||
return d
|
||||
|
||||
def _setup_lbry_file_opener(self):
|
||||
stream_info_manager = TempLBRYFileMetadataManager()
|
||||
downloader_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
downloader_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
self.session.blob_manager, stream_info_manager,
|
||||
self.session.wallet)
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory)
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory)
|
||||
return defer.succeed(True)
|
||||
|
||||
def _setup_control_handlers(self):
|
||||
|
@ -323,20 +323,20 @@ class LBRYConsole():
|
|||
ModifyApplicationDefaultsFactory(self),
|
||||
ShutDownFactory(self),
|
||||
PeerStatsAndSettingsChooserFactory(self.session.peer_manager),
|
||||
LBRYFileStatusFactory(self.lbry_file_manager),
|
||||
EncryptedFileStatusFactory(self.lbry_file_manager),
|
||||
AddStreamFromSDFactory(self.sd_identifier, self.session.base_payment_rate_manager,
|
||||
self.session.wallet),
|
||||
DeleteLBRYFileChooserFactory(self.lbry_file_metadata_manager, self.session.blob_manager,
|
||||
DeleteEncryptedFileChooserFactory(self.lbry_file_metadata_manager, self.session.blob_manager,
|
||||
self.lbry_file_manager),
|
||||
ToggleLBRYFileRunningChooserFactory(self.lbry_file_manager),
|
||||
CreateLBRYFileFactory(self.session, self.lbry_file_manager),
|
||||
ToggleEncryptedFileRunningChooserFactory(self.lbry_file_manager),
|
||||
CreateEncryptedFileFactory(self.session, self.lbry_file_manager),
|
||||
PublishStreamDescriptorChooserFactory(self.lbry_file_metadata_manager,
|
||||
self.session.blob_manager),
|
||||
ShowPublishedSDHashesChooserFactory(self.lbry_file_metadata_manager,
|
||||
self.lbry_file_manager),
|
||||
CreatePlainStreamDescriptorChooserFactory(self.lbry_file_manager),
|
||||
ShowLBRYFileStreamHashChooserFactory(self.lbry_file_manager),
|
||||
ModifyLBRYFileOptionsChooserFactory(self.lbry_file_manager),
|
||||
ShowEncryptedFileStreamHashChooserFactory(self.lbry_file_manager),
|
||||
ModifyEncryptedFileOptionsChooserFactory(self.lbry_file_manager),
|
||||
AddStreamFromHashFactory(self.sd_identifier, self.session, self.session.wallet),
|
||||
StatusFactory(self, self.session.rate_limiter, self.lbry_file_manager,
|
||||
self.session.blob_manager, self.session.wallet if not self.fake_wallet else None),
|
||||
|
@ -565,7 +565,7 @@ def launch_lbry_console():
|
|||
logger.addHandler(file_handler)
|
||||
|
||||
|
||||
console = LBRYConsole(peer_port, dht_node_port, bootstrap_nodes, fake_wallet=args.fake_wallet,
|
||||
console = Console(peer_port, dht_node_port, bootstrap_nodes, fake_wallet=args.fake_wallet,
|
||||
lbrycrd_conf=args.lbrycrd_wallet_conf, lbrycrd_dir=args.lbrycrd_wallet_dir,
|
||||
use_upnp=not args.disable_upnp, data_dir=data_dir,
|
||||
created_data_dir=created_data_dir, lbrycrdd_path=args.lbrycrdd_path)
|
|
@ -2,8 +2,8 @@ import logging
|
|||
|
||||
from zope.interface import implements
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
|
||||
from lbrynet.lbryfilemanager.EncryptedFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
||||
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob, create_plain_sd
|
||||
from lbrynet.lbrynet_console.interfaces import ICommandHandler, ICommandHandlerFactory
|
||||
from lbrynet.core.StreamDescriptor import download_sd_blob
|
||||
|
@ -418,7 +418,7 @@ class ShutDownFactory(CommandHandlerFactory):
|
|||
full_help = "Shut down"
|
||||
|
||||
|
||||
class LBRYFileStatus(CommandHandler):
|
||||
class EncryptedFileStatus(CommandHandler):
|
||||
#prompt_description = "Print status information for all LBRY Files"
|
||||
|
||||
def __init__(self, console, lbry_file_manager):
|
||||
|
@ -446,8 +446,8 @@ class LBRYFileStatus(CommandHandler):
|
|||
self.console.sendLine(''.join(status_strings))
|
||||
|
||||
|
||||
class LBRYFileStatusFactory(CommandHandlerFactory):
|
||||
control_handler_class = LBRYFileStatus
|
||||
class EncryptedFileStatusFactory(CommandHandlerFactory):
|
||||
control_handler_class = EncryptedFileStatus
|
||||
command = "lbryfile-status"
|
||||
short_help = "Print status information for LBRY files"
|
||||
full_help = "Print the status information for all streams that are being saved to disk." \
|
||||
|
@ -988,7 +988,7 @@ class AddStreamFromLBRYcrdNameFactory(CommandHandlerFactory):
|
|||
"Usage: get <name>"
|
||||
|
||||
|
||||
class LBRYFileChooser(RecursiveCommandHandler):
|
||||
class EncryptedFileChooser(RecursiveCommandHandler):
|
||||
|
||||
def __init__(self, console, lbry_file_manager, factory_class, *args, **kwargs):
|
||||
"""
|
||||
|
@ -1014,23 +1014,23 @@ class LBRYFileChooser(RecursiveCommandHandler):
|
|||
return control_handler_factories
|
||||
|
||||
|
||||
class LBRYFileChooserFactory(CommandHandlerFactory):
|
||||
class EncryptedFileChooserFactory(CommandHandlerFactory):
|
||||
def get_prompt_description(self):
|
||||
lbry_file = self.args[0]
|
||||
return lbry_file.file_name
|
||||
|
||||
|
||||
class DeleteLBRYFileChooser(LBRYFileChooser):
|
||||
class DeleteEncryptedFileChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Delete LBRY File"
|
||||
|
||||
def __init__(self, console, stream_info_manager, blob_manager, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, DeleteLBRYFileFactory,
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, DeleteEncryptedFileFactory,
|
||||
stream_info_manager, blob_manager, lbry_file_manager,
|
||||
exit_after_one_done=True)
|
||||
|
||||
|
||||
class DeleteLBRYFileChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = DeleteLBRYFileChooser
|
||||
class DeleteEncryptedFileChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = DeleteEncryptedFileChooser
|
||||
command = "delete-lbryfile"
|
||||
short_help = "Delete an LBRY file"
|
||||
full_help = "Delete an LBRY file which has been downloaded or created by this application.\n" \
|
||||
|
@ -1040,7 +1040,7 @@ class DeleteLBRYFileChooserFactory(CommandHandlerFactory):
|
|||
"not be able to upload those chunks of data to other peers on LBRYnet."
|
||||
|
||||
|
||||
class DeleteLBRYFile(CommandHandler):
|
||||
class DeleteEncryptedFile(CommandHandler):
|
||||
#prompt_description = "Delete LBRY File"
|
||||
delete_data_prompt = "Also delete data? (y/n): "
|
||||
confirm_prompt = "Are you sure? (y/n): "
|
||||
|
@ -1106,27 +1106,27 @@ class DeleteLBRYFile(CommandHandler):
|
|||
return d
|
||||
|
||||
|
||||
class DeleteLBRYFileFactory(LBRYFileChooserFactory):
|
||||
control_handler_class = DeleteLBRYFile
|
||||
class DeleteEncryptedFileFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = DeleteEncryptedFile
|
||||
|
||||
|
||||
class ToggleLBRYFileRunningChooser(LBRYFileChooser):
|
||||
class ToggleEncryptedFileRunningChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Toggle whether an LBRY File is running"
|
||||
|
||||
def __init__(self, console, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, ToggleLBRYFileRunningFactory,
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, ToggleEncryptedFileRunningFactory,
|
||||
lbry_file_manager, exit_after_one_done=True)
|
||||
|
||||
|
||||
class ToggleLBRYFileRunningChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ToggleLBRYFileRunningChooser
|
||||
class ToggleEncryptedFileRunningChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ToggleEncryptedFileRunningChooser
|
||||
command = "toggle-running"
|
||||
short_help = "Toggle whether an LBRY file is running"
|
||||
full_help = "Toggle whether an LBRY file, which is being saved by this application," \
|
||||
"is currently being downloaded."
|
||||
|
||||
|
||||
class ToggleLBRYFileRunning(CommandHandler):
|
||||
class ToggleEncryptedFileRunning(CommandHandler):
|
||||
#prompt_description = "Toggle whether an LBRY File is running"
|
||||
|
||||
def __init__(self, console, lbry_file, lbry_file_manager):
|
||||
|
@ -1151,11 +1151,11 @@ class ToggleLBRYFileRunning(CommandHandler):
|
|||
return "An unexpected error occurred. See %s for details." % log_file
|
||||
|
||||
|
||||
class ToggleLBRYFileRunningFactory(LBRYFileChooserFactory):
|
||||
control_handler_class = ToggleLBRYFileRunning
|
||||
class ToggleEncryptedFileRunningFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = ToggleEncryptedFileRunning
|
||||
|
||||
|
||||
class CreateLBRYFile(CommandHandler):
|
||||
class CreateEncryptedFile(CommandHandler):
|
||||
#prompt_description = "Create an LBRY File from file"
|
||||
line_prompt = "File name: "
|
||||
|
||||
|
@ -1179,13 +1179,13 @@ class CreateLBRYFile(CommandHandler):
|
|||
|
||||
def set_status(self, lbry_file_downloader):
|
||||
d = self.lbry_file_manager.change_lbry_file_status(lbry_file_downloader,
|
||||
ManagedLBRYFileDownloader.STATUS_FINISHED)
|
||||
ManagedEncryptedFileDownloader.STATUS_FINISHED)
|
||||
d.addCallback(lambda _: lbry_file_downloader.restore())
|
||||
return d
|
||||
|
||||
|
||||
class CreateLBRYFileFactory(CommandHandlerFactory):
|
||||
control_handler_class = CreateLBRYFile
|
||||
class CreateEncryptedFileFactory(CommandHandlerFactory):
|
||||
control_handler_class = CreateEncryptedFile
|
||||
command = "create-lbryfile"
|
||||
short_help = "LBRYize a file"
|
||||
full_help = "Encrypt a file, split it into chunks, and make those chunks available on LBRYnet. Also " \
|
||||
|
@ -1196,11 +1196,11 @@ class CreateLBRYFileFactory(CommandHandlerFactory):
|
|||
"downloaded via the hash of the stream descriptor."
|
||||
|
||||
|
||||
class PublishStreamDescriptorChooser(LBRYFileChooser):
|
||||
class PublishStreamDescriptorChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Publish a stream descriptor file to the DHT for an LBRY File"
|
||||
|
||||
def __init__(self, console, stream_info_manager, blob_manager, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, PublishStreamDescriptorFactory,
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, PublishStreamDescriptorFactory,
|
||||
stream_info_manager, blob_manager, lbry_file_manager,
|
||||
exit_after_one_done=True)
|
||||
|
||||
|
@ -1243,15 +1243,15 @@ class PublishStreamDescriptor(CommandHandler):
|
|||
# return d
|
||||
|
||||
|
||||
class PublishStreamDescriptorFactory(LBRYFileChooserFactory):
|
||||
class PublishStreamDescriptorFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = PublishStreamDescriptor
|
||||
|
||||
|
||||
class ShowPublishedSDHashesChooser(LBRYFileChooser):
|
||||
class ShowPublishedSDHashesChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Show published stream descriptors for an LBRY File"
|
||||
|
||||
def __init__(self, console, stream_info_manager, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, ShowPublishedSDHashesFactory,
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, ShowPublishedSDHashesFactory,
|
||||
stream_info_manager, lbry_file_manager)
|
||||
|
||||
|
||||
|
@ -1288,15 +1288,15 @@ class ShowPublishedSDHashes(CommandHandler):
|
|||
return d
|
||||
|
||||
|
||||
class ShowPublishedSDHashesFactory(LBRYFileChooserFactory):
|
||||
class ShowPublishedSDHashesFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = ShowPublishedSDHashes
|
||||
|
||||
|
||||
class CreatePlainStreamDescriptorChooser(LBRYFileChooser):
|
||||
class CreatePlainStreamDescriptorChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Create a plain stream descriptor file for an LBRY File"
|
||||
|
||||
def __init__(self, console, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager,
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager,
|
||||
CreatePlainStreamDescriptorFactory, lbry_file_manager,
|
||||
exit_after_one_done=True)
|
||||
|
||||
|
@ -1352,26 +1352,26 @@ class CreatePlainStreamDescriptor(CommandHandler):
|
|||
return defer.succeed(file_name)
|
||||
|
||||
|
||||
class CreatePlainStreamDescriptorFactory(LBRYFileChooserFactory):
|
||||
class CreatePlainStreamDescriptorFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = CreatePlainStreamDescriptor
|
||||
|
||||
|
||||
class ShowLBRYFileStreamHashChooser(LBRYFileChooser):
|
||||
class ShowEncryptedFileStreamHashChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Show an LBRY File's stream hash (not usually what you want)"
|
||||
|
||||
def __init__(self, console, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, ShowLBRYFileStreamHashFactory)
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, ShowEncryptedFileStreamHashFactory)
|
||||
|
||||
|
||||
class ShowLBRYFileStreamHashChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ShowLBRYFileStreamHashChooser
|
||||
class ShowEncryptedFileStreamHashChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ShowEncryptedFileStreamHashChooser
|
||||
command = "lbryfile-streamhash"
|
||||
short_help = "Show an LBRY file's stream hash"
|
||||
full_help = "Show the stream hash of an LBRY file, which is how the LBRY file is referenced internally" \
|
||||
" by this application and therefore not usually what you want to see."
|
||||
|
||||
|
||||
class ShowLBRYFileStreamHash(CommandHandler):
|
||||
class ShowEncryptedFileStreamHash(CommandHandler):
|
||||
#prompt_description = "Show an LBRY File's stream hash (not usually what you want)"
|
||||
|
||||
def __init__(self, console, lbry_file):
|
||||
|
@ -1383,11 +1383,11 @@ class ShowLBRYFileStreamHash(CommandHandler):
|
|||
self.finished_deferred.callback(None)
|
||||
|
||||
|
||||
class ShowLBRYFileStreamHashFactory(LBRYFileChooserFactory):
|
||||
control_handler_class = ShowLBRYFileStreamHash
|
||||
class ShowEncryptedFileStreamHashFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = ShowEncryptedFileStreamHash
|
||||
|
||||
|
||||
class ModifyLBRYFileDataPaymentRate(ModifyPaymentRate):
|
||||
class ModifyEncryptedFileDataPaymentRate(ModifyPaymentRate):
|
||||
prompt_description = "Modify LBRY File data payment rate"
|
||||
|
||||
def __init__(self, console, lbry_file, lbry_file_manager):
|
||||
|
@ -1415,19 +1415,19 @@ class ModifyLBRYFileDataPaymentRate(ModifyPaymentRate):
|
|||
return status
|
||||
|
||||
|
||||
class ModifyLBRYFileDataPaymentRateFactory(CommandHandlerFactory):
|
||||
control_handler_class = ModifyLBRYFileDataPaymentRate
|
||||
class ModifyEncryptedFileDataPaymentRateFactory(CommandHandlerFactory):
|
||||
control_handler_class = ModifyEncryptedFileDataPaymentRate
|
||||
|
||||
|
||||
class ModifyLBRYFileOptionsChooser(LBRYFileChooser):
|
||||
class ModifyEncryptedFileOptionsChooser(EncryptedFileChooser):
|
||||
#prompt_description = "Modify an LBRY File's options"
|
||||
|
||||
def __init__(self, console, lbry_file_manager):
|
||||
LBRYFileChooser.__init__(self, console, lbry_file_manager, ModifyLBRYFileOptionsFactory, lbry_file_manager)
|
||||
EncryptedFileChooser.__init__(self, console, lbry_file_manager, ModifyEncryptedFileOptionsFactory, lbry_file_manager)
|
||||
|
||||
|
||||
class ModifyLBRYFileOptionsChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ModifyLBRYFileOptionsChooser
|
||||
class ModifyEncryptedFileOptionsChooserFactory(CommandHandlerFactory):
|
||||
control_handler_class = ModifyEncryptedFileOptionsChooser
|
||||
command = "modify-lbryfile-options"
|
||||
short_help = "Modify an LBRY file's options"
|
||||
full_help = "Modify an LBRY file's options. Options include, and are limited to, " \
|
||||
|
@ -1435,7 +1435,7 @@ class ModifyLBRYFileOptionsChooserFactory(CommandHandlerFactory):
|
|||
"this LBRY file."
|
||||
|
||||
|
||||
class ModifyLBRYFileOptions(RecursiveCommandHandler):
|
||||
class ModifyEncryptedFileOptions(RecursiveCommandHandler):
|
||||
#prompt_description = "Modify an LBRY File's options"
|
||||
|
||||
def __init__(self, console, lbry_file, lbry_file_manager):
|
||||
|
@ -1445,12 +1445,12 @@ class ModifyLBRYFileOptions(RecursiveCommandHandler):
|
|||
|
||||
def _get_control_handler_factories(self):
|
||||
factories = []
|
||||
factories.append(ModifyLBRYFileDataPaymentRateFactory(self.lbry_file, self.lbry_file_manager))
|
||||
factories.append(ModifyEncryptedFileDataPaymentRateFactory(self.lbry_file, self.lbry_file_manager))
|
||||
return factories
|
||||
|
||||
|
||||
class ModifyLBRYFileOptionsFactory(LBRYFileChooserFactory):
|
||||
control_handler_class = ModifyLBRYFileOptions
|
||||
class ModifyEncryptedFileOptionsFactory(EncryptedFileChooserFactory):
|
||||
control_handler_class = ModifyEncryptedFileOptions
|
||||
|
||||
|
||||
class ClaimName(CommandHandler):
|
||||
|
@ -1821,7 +1821,7 @@ class Publish(CommandHandler):
|
|||
def set_status(self, lbry_file_downloader):
|
||||
self.lbry_file = lbry_file_downloader
|
||||
d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file,
|
||||
ManagedLBRYFileDownloader.STATUS_FINISHED)
|
||||
ManagedEncryptedFileDownloader.STATUS_FINISHED)
|
||||
d.addCallback(lambda _: lbry_file_downloader.restore())
|
||||
return d
|
||||
|
||||
|
@ -2354,7 +2354,7 @@ class PeerStatsAndSettingsChooserFactory(CommandHandlerFactory):
|
|||
"which peers to connect to."
|
||||
|
||||
|
||||
class LBRYFileStatusModifier(CommandHandler):
|
||||
class EncryptedFileStatusModifier(CommandHandler):
|
||||
def __init__(self, console, lbry_file, stream_info_manager, blob_manager, lbry_file_manager):
|
||||
CommandHandler.__init__(self, console)
|
||||
self.lbry_file = lbry_file
|
||||
|
@ -2371,11 +2371,11 @@ class LBRYFileStatusModifier(CommandHandler):
|
|||
if self.current_handler is None:
|
||||
if line:
|
||||
if line.lower() == 'd':
|
||||
self.current_handler = DeleteLBRYFile(self.console, self.lbry_file,
|
||||
self.current_handler = DeleteEncryptedFile(self.console, self.lbry_file,
|
||||
self.stream_info_manager, self.blob_manager,
|
||||
self.lbry_file_manager)
|
||||
elif line.lower() == 't':
|
||||
self.current_handler = ToggleLBRYFileRunning(self.console, self.lbry_file,
|
||||
self.current_handler = ToggleEncryptedFileRunning(self.console, self.lbry_file,
|
||||
self.lbry_file_manager)
|
||||
else:
|
||||
self.console.sendLine("Invalid selection\n")
|
||||
|
@ -2444,7 +2444,7 @@ class Status(CommandHandler):
|
|||
self.console.sendLine("Invalid choice.\n")
|
||||
self.finished_deferred.callback(None)
|
||||
return
|
||||
self.current_handler = LBRYFileStatusModifier(self.console, self.lbry_files[index],
|
||||
self.current_handler = EncryptedFileStatusModifier(self.console, self.lbry_files[index],
|
||||
self.lbry_file_manager.stream_info_manager,
|
||||
self.blob_manager, self.lbry_file_manager)
|
||||
try:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from yapsy.IPlugin import IPlugin
|
||||
|
||||
|
||||
class LBRYPlugin(IPlugin):
|
||||
class Plugin(IPlugin):
|
||||
|
||||
def __init__(self):
|
||||
IPlugin.__init__(self)
|
|
@ -18,7 +18,7 @@ def run_in_thread(fn):
|
|||
return wrapped
|
||||
|
||||
|
||||
class LBRYSettings(object):
|
||||
class Settings(object):
|
||||
NAME = "settings.db"
|
||||
def __init__(self, db_dir):
|
||||
self.db_dir = db_dir
|
|
@ -1,4 +1,4 @@
|
|||
from lbrynet.lbrynet_console import LBRYPlugin
|
||||
from lbrynet.lbrynet_console import Plugin
|
||||
from twisted.internet import defer
|
||||
from lbrynet.conf import MIN_VALUABLE_BLOB_HASH_PAYMENT_RATE, MIN_VALUABLE_BLOB_INFO_PAYMENT_RATE
|
||||
from BlindRepeater import BlindRepeater
|
||||
|
@ -13,10 +13,10 @@ from ValuableBlobQueryHandler import ValuableBlobHashQueryHandlerFactory
|
|||
from PaymentRateManager import BlindRepeaterPaymentRateManager
|
||||
|
||||
|
||||
class BlindRepeaterPlugin(LBRYPlugin.LBRYPlugin):
|
||||
class BlindRepeaterPlugin(Plugin.Plugin):
|
||||
|
||||
def __init__(self):
|
||||
LBRYPlugin.LBRYPlugin.__init__(self)
|
||||
Plugin.Plugin.__init__(self)
|
||||
self.enabled = False
|
||||
self.blind_info_manager = None
|
||||
self.valuable_blob_length_query_handler = None
|
||||
|
|
|
@ -32,19 +32,19 @@ from lbrynet.core.server.BlobAvailabilityHandler import BlobAvailabilityHandlerF
|
|||
from lbrynet.core.server.BlobRequestHandler import BlobRequestHandlerFactory
|
||||
from lbrynet.core.server.ServerProtocol import ServerProtocolFactory
|
||||
from lbrynet.core.Error import UnknownNameError, InsufficientFundsError, InvalidNameError
|
||||
from lbrynet.lbryfile.StreamDescriptor import LBRYFileStreamType
|
||||
from lbrynet.lbryfile.client.LBRYFileDownloader import LBRYFileSaverFactory, LBRYFileOpenerFactory
|
||||
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbrynet_daemon.LBRYUIManager import LBRYUIManager
|
||||
from lbrynet.lbrynet_daemon.LBRYDownloader import GetStream
|
||||
from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
||||
from lbrynet.lbrynet_daemon.LBRYExchangeRateManager import ExchangeRateManager
|
||||
from lbrynet.lbryfile.StreamDescriptor import EncryptedFileStreamType
|
||||
from lbrynet.lbryfile.client.EncryptedFileDownloader import EncryptedFileSaverFactory, EncryptedFileOpenerFactory
|
||||
from lbrynet.lbryfile.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbrynet_daemon.UIManager import UIManager
|
||||
from lbrynet.lbrynet_daemon.Downloader import GetStream
|
||||
from lbrynet.lbrynet_daemon.Publisher import Publisher
|
||||
from lbrynet.lbrynet_daemon.ExchangeRateManager import ExchangeRateManager
|
||||
from lbrynet.lbrynet_daemon.Lighthouse import LighthouseClient
|
||||
from lbrynet.metadata.LBRYMetadata import Metadata, verify_name_characters
|
||||
from lbrynet.metadata.Metadata import Metadata, verify_name_characters
|
||||
from lbrynet.core import log_support
|
||||
from lbrynet.core import utils
|
||||
from lbrynet.core.utils import generate_id
|
||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||
from lbrynet.lbrynet_console.Settings import Settings
|
||||
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS, \
|
||||
KNOWN_DHT_NODES, DEFAULT_MAX_KEY_FEE, DEFAULT_WALLET, \
|
||||
DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME, DEFAULT_UI_BRANCH, \
|
||||
|
@ -52,11 +52,11 @@ from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS,
|
|||
from lbrynet.conf import DEFAULT_SD_DOWNLOAD_TIMEOUT
|
||||
from lbrynet.conf import DEFAULT_TIMEOUT
|
||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob, BlobStreamDescriptorReader
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.core.PTCWallet import PTCWallet
|
||||
from lbrynet.core.LBRYWallet import LBRYcrdWallet, LBRYumWallet
|
||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||
from lbrynet.lbryfile.LBRYFileMetadataManager import DBLBRYFileMetadataManager, TempLBRYFileMetadataManager
|
||||
from lbrynet.core.Wallet import LBRYcrdWallet, LBRYumWallet
|
||||
from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager
|
||||
from lbrynet.lbryfile.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager, TempEncryptedFileMetadataManager
|
||||
from lbrynet import reflector
|
||||
|
||||
|
||||
|
@ -75,9 +75,9 @@ log = logging.getLogger(__name__)
|
|||
|
||||
if os.path.isfile(lbrynet_log):
|
||||
with open(lbrynet_log, 'r') as f:
|
||||
PREVIOUS_LBRYNET_LOG = len(f.read())
|
||||
PREVIOUS_NET_LOG = len(f.read())
|
||||
else:
|
||||
PREVIOUS_LBRYNET_LOG = 0
|
||||
PREVIOUS_NET_LOG = 0
|
||||
|
||||
INITIALIZING_CODE = 'initializing'
|
||||
LOADING_DB_CODE = 'loading_db'
|
||||
|
@ -138,7 +138,7 @@ class Parameters(object):
|
|||
self.__dict__.update(kwargs)
|
||||
|
||||
|
||||
class LBRYDaemon(jsonrpc.JSONRPC):
|
||||
class Daemon(jsonrpc.JSONRPC):
|
||||
"""
|
||||
LBRYnet daemon, a jsonrpc interface to lbry functions
|
||||
"""
|
||||
|
@ -379,9 +379,9 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
# self.lbrynet_connection_checker = LoopingCall(self._check_lbrynet_connection)
|
||||
|
||||
self.sd_identifier = StreamDescriptorIdentifier()
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.settings = LBRYSettings(self.db_dir)
|
||||
self.lbry_ui_manager = LBRYUIManager(root)
|
||||
self.stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
self.settings = Settings(self.db_dir)
|
||||
self.lbry_ui_manager = UIManager(root)
|
||||
self.blob_request_payment_rate_manager = None
|
||||
self.lbry_file_metadata_manager = None
|
||||
self.lbry_file_manager = None
|
||||
|
@ -561,10 +561,13 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
self.send_heartbeat.start(60)
|
||||
|
||||
def _send_heartbeat(self):
|
||||
log.debug('Sending heartbeat')
|
||||
heartbeat = self._events.heartbeat()
|
||||
self.analytics_api.track(heartbeat)
|
||||
|
||||
def _send_download_started(self, name, stream_info=None):
|
||||
event = self._events.download_started(name, stream_info)
|
||||
self.analytics_api.track(event)
|
||||
|
||||
def _get_platform(self):
|
||||
r = {
|
||||
"processor": platform.processor(),
|
||||
|
@ -688,7 +691,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
self._add_to_pending_claims(name, txid)
|
||||
|
||||
def _process_lbry_file(name, lbry_file):
|
||||
# lbry_file is an instance of ManagedLBRYFileDownloader or None
|
||||
# lbry_file is an instance of ManagedEncryptedFileDownloader or None
|
||||
# TODO: check for sd_hash in addition to txid
|
||||
ready_to_start = (
|
||||
lbry_file and
|
||||
|
@ -812,11 +815,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
|
||||
def _upload_log(self, log_type=None, exclude_previous=False, force=False):
|
||||
if self.upload_log or force:
|
||||
for lm, lp in [('lbrynet', lbrynet_log)]: #, ('lbryum', lbryum_log)]:
|
||||
for lm, lp in [('lbrynet', lbrynet_log)]:
|
||||
if os.path.isfile(lp):
|
||||
if exclude_previous:
|
||||
f = open(lp, "r")
|
||||
f.seek(PREVIOUS_LBRYNET_LOG) # if lm == 'lbrynet' else PREVIOUS_LBRYUM_LOG)
|
||||
f.seek(PREVIOUS_NET_LOG)
|
||||
log_contents = f.read()
|
||||
f.close()
|
||||
else:
|
||||
|
@ -1022,11 +1025,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
|
||||
def _setup_lbry_file_manager(self):
|
||||
self.startup_status = STARTUP_STAGES[3]
|
||||
self.lbry_file_metadata_manager = DBLBRYFileMetadataManager(self.db_dir)
|
||||
self.lbry_file_metadata_manager = DBEncryptedFileMetadataManager(self.db_dir)
|
||||
d = self.lbry_file_metadata_manager.setup()
|
||||
|
||||
def set_lbry_file_manager():
|
||||
self.lbry_file_manager = LBRYFileManager(self.session,
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session,
|
||||
self.lbry_file_metadata_manager,
|
||||
self.sd_identifier,
|
||||
download_directory=self.download_directory)
|
||||
|
@ -1073,7 +1076,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
return r
|
||||
|
||||
def create_session(results):
|
||||
self.session = LBRYSession(results['default_data_payment_rate'], db_dir=self.db_dir, lbryid=self.lbryid,
|
||||
self.session = Session(results['default_data_payment_rate'], db_dir=self.db_dir, lbryid=self.lbryid,
|
||||
blob_dir=self.blobfile_dir, dht_node_port=self.dht_node_port,
|
||||
known_dht_nodes=self.known_dht_nodes, peer_port=self.peer_port,
|
||||
use_upnp=self.use_upnp, wallet=results['wallet'])
|
||||
|
@ -1087,22 +1090,22 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
return dl
|
||||
|
||||
def _setup_stream_identifier(self):
|
||||
file_saver_factory = LBRYFileSaverFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
file_saver_factory = EncryptedFileSaverFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
self.session.blob_manager, self.stream_info_manager,
|
||||
self.session.wallet, self.download_directory)
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_saver_factory)
|
||||
file_opener_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, file_saver_factory)
|
||||
file_opener_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
self.session.blob_manager, self.stream_info_manager,
|
||||
self.session.wallet)
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, file_opener_factory)
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, file_opener_factory)
|
||||
return defer.succeed(None)
|
||||
|
||||
def _setup_lbry_file_opener(self):
|
||||
|
||||
downloader_factory = LBRYFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
downloader_factory = EncryptedFileOpenerFactory(self.session.peer_finder, self.session.rate_limiter,
|
||||
self.session.blob_manager, self.stream_info_manager,
|
||||
self.session.wallet)
|
||||
self.sd_identifier.add_stream_downloader_factory(LBRYFileStreamType, downloader_factory)
|
||||
self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, downloader_factory)
|
||||
return defer.succeed(True)
|
||||
|
||||
def _download_sd_blob(self, sd_hash, timeout=DEFAULT_SD_DOWNLOAD_TIMEOUT):
|
||||
|
@ -1129,6 +1132,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
Add a lbry file to the file manager, start the download, and return the new lbry file.
|
||||
If it already exists in the file manager, return the existing lbry file
|
||||
"""
|
||||
self._send_download_started(name)
|
||||
helper = _DownloadNameHelper(
|
||||
self, name, timeout, download_directory, file_name, wait_for_write)
|
||||
|
||||
|
@ -1175,7 +1179,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
|||
force_refresh: if True, always go out to the blockchain to resolve.
|
||||
"""
|
||||
if name.startswith('lbry://'):
|
||||
raise ValueError('name %s should not start with lbry://')
|
||||
raise ValueError('name {} should not start with lbry://'.format(name))
|
||||
helper = _ResolveNameHelper(self, name, force_refresh)
|
||||
return helper.get_deferred()
|
||||
|
||||
|
@ -2650,16 +2654,14 @@ class _DownloadNameHelper(object):
|
|||
def _setup_stream(self, stream_info):
|
||||
stream_hash = get_sd_hash(stream_info)
|
||||
d = self.daemon._get_lbry_file_by_sd_hash(stream_hash)
|
||||
d.addCallback(self._add_results_callback(stream_info))
|
||||
d.addCallback(self._prepend_stream_info, stream_info)
|
||||
return d
|
||||
|
||||
def _add_results_callback(self, stream_info):
|
||||
def add_results(l):
|
||||
if l:
|
||||
if os.path.isfile(os.path.join(self.download_directory, l.file_name)):
|
||||
return defer.succeed((stream_info, l))
|
||||
return defer.succeed((stream_info, None))
|
||||
return add_results
|
||||
def _prepend_stream_info(self, lbry_file, stream_info):
|
||||
if lbry_file:
|
||||
if os.path.isfile(os.path.join(self.download_directory, lbry_file.file_name)):
|
||||
return defer.succeed((stream_info, lbry_file))
|
||||
return defer.succeed((stream_info, None))
|
||||
|
||||
def wait_or_get_stream(self, args):
|
||||
stream_info, lbry_file = args
|
|
@ -12,7 +12,7 @@ from twisted.internet import reactor, defer
|
|||
from jsonrpc.proxy import JSONRPCProxy
|
||||
|
||||
from lbrynet.core import log_support
|
||||
from lbrynet.lbrynet_daemon.LBRYDaemonServer import LBRYDaemonServer, LBRYDaemonRequest
|
||||
from lbrynet.lbrynet_daemon.DaemonServer import DaemonServer, DaemonRequest
|
||||
from lbrynet.conf import API_CONNECTION_STRING, API_INTERFACE, API_PORT, \
|
||||
UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
|
||||
|
||||
|
@ -107,7 +107,7 @@ def start():
|
|||
print "To quit press ctrl-c or call 'stop' via the API"
|
||||
|
||||
if test_internet_connection():
|
||||
lbry = LBRYDaemonServer()
|
||||
lbry = DaemonServer()
|
||||
|
||||
d = lbry.start(branch=args.branch if args.branch else DEFAULT_UI_BRANCH,
|
||||
user_specified=args.ui,
|
||||
|
@ -117,7 +117,7 @@ def start():
|
|||
d.addCallback(lambda _: webbrowser.open(UI_ADDRESS))
|
||||
|
||||
lbrynet_server = server.Site(lbry.root)
|
||||
lbrynet_server.requestFactory = LBRYDaemonRequest
|
||||
lbrynet_server.requestFactory = DaemonRequest
|
||||
reactor.listenTCP(API_PORT, lbrynet_server, interface=API_INTERFACE)
|
||||
reactor.run()
|
||||
|
|
@ -15,11 +15,11 @@ from twisted.internet import defer, interfaces, error, reactor, threads
|
|||
|
||||
from zope.interface import implements
|
||||
|
||||
from lbrynet.lbrynet_daemon.LBRYDaemon import LBRYDaemon
|
||||
from lbrynet.lbrynet_daemon.Daemon import Daemon
|
||||
from lbrynet.conf import API_ADDRESS, UI_ADDRESS, DEFAULT_UI_BRANCH, LOG_FILE_NAME
|
||||
|
||||
|
||||
# TODO: omg, this code is essentially duplicated in LBRYDaemon
|
||||
# TODO: omg, this code is essentially duplicated in Daemon
|
||||
if sys.platform != "darwin":
|
||||
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
|
||||
else:
|
||||
|
@ -31,7 +31,7 @@ lbrynet_log = os.path.join(data_dir, LOG_FILE_NAME)
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYDaemonRequest(server.Request):
|
||||
class DaemonRequest(server.Request):
|
||||
"""
|
||||
For LBRY specific request functionality. Currently just provides
|
||||
handling for large multipart POST requests, taken from here:
|
||||
|
@ -231,7 +231,7 @@ class LBRYindex(resource.Resource):
|
|||
return static.File(os.path.join(self.ui_dir, "index.html")).render_GET(request)
|
||||
|
||||
|
||||
class LBRYFileStreamer(object):
|
||||
class EncryptedFileStreamer(object):
|
||||
"""
|
||||
Writes downloaded LBRY file to request as the download comes in, pausing and resuming as requested
|
||||
used for Chrome
|
||||
|
@ -315,13 +315,13 @@ class LBRYFileStreamer(object):
|
|||
return defer.succeed(None)
|
||||
|
||||
|
||||
class HostedLBRYFile(resource.Resource):
|
||||
class HostedEncryptedFile(resource.Resource):
|
||||
def __init__(self, api):
|
||||
self._api = api
|
||||
self._producer = None
|
||||
resource.Resource.__init__(self)
|
||||
|
||||
# todo: fix LBRYFileStreamer and use it instead of static.File
|
||||
# todo: fix EncryptedFileStreamer and use it instead of static.File
|
||||
# def makeProducer(self, request, stream):
|
||||
# def _save_producer(producer):
|
||||
# self._producer = producer
|
||||
|
@ -333,7 +333,7 @@ class HostedLBRYFile(resource.Resource):
|
|||
# path = os.path.join(self._api.download_directory, stream.file_name)
|
||||
#
|
||||
# d = stream.get_total_bytes()
|
||||
# d.addCallback(lambda size: _save_producer(LBRYFileStreamer(request, path, start, stop, size)))
|
||||
# d.addCallback(lambda size: _save_producer(EncryptedFileStreamer(request, path, start, stop, size)))
|
||||
# d.addCallback(lambda _: request.registerProducer(self._producer, streaming=True))
|
||||
# # request.notifyFinish().addCallback(lambda _: self._producer.stopProducing())
|
||||
# request.notifyFinish().addErrback(self._responseFailed, d)
|
||||
|
@ -362,7 +362,7 @@ class HostedLBRYFile(resource.Resource):
|
|||
# call.addErrback(lambda err: log.info("Error: " + str(err)))
|
||||
# call.cancel()
|
||||
|
||||
class LBRYFileUpload(resource.Resource):
|
||||
class EncryptedFileUpload(resource.Resource):
|
||||
"""
|
||||
Accepts a file sent via the file upload widget in the web UI, saves
|
||||
it into a temporary dir, and responds with a JSON string containing
|
||||
|
@ -401,12 +401,12 @@ class LBRYFileUpload(resource.Resource):
|
|||
return json.dumps(newpath)
|
||||
|
||||
|
||||
class LBRYDaemonServer(object):
|
||||
class DaemonServer(object):
|
||||
def _setup_server(self, wallet):
|
||||
self.root = LBRYindex(os.path.join(os.path.join(data_dir, "lbry-ui"), "active"))
|
||||
self._api = LBRYDaemon(self.root, wallet_type=wallet)
|
||||
self.root.putChild("view", HostedLBRYFile(self._api))
|
||||
self.root.putChild("upload", LBRYFileUpload(self._api))
|
||||
self._api = Daemon(self.root, wallet_type=wallet)
|
||||
self.root.putChild("view", HostedEncryptedFile(self._api))
|
||||
self.root.putChild("upload", EncryptedFileUpload(self._api))
|
||||
self.root.putChild(API_ADDRESS, self._api)
|
||||
return defer.succeed(True)
|
||||
|
|
@ -11,8 +11,8 @@ from twisted.internet.task import LoopingCall
|
|||
from lbrynet.core.Error import InsufficientFundsError, KeyFeeAboveMaxAllowed
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.core.StreamDescriptor import download_sd_blob
|
||||
from lbrynet.metadata.LBRYFee import LBRYFeeValidator
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloaderFactory
|
||||
from lbrynet.metadata.Fee import FeeValidator
|
||||
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloaderFactory
|
||||
from lbrynet.conf import DEFAULT_TIMEOUT, LOG_FILE_NAME
|
||||
|
||||
INITIALIZING_CODE = 'initializing'
|
||||
|
@ -86,7 +86,7 @@ class GetStream(object):
|
|||
|
||||
def _convert_max_fee(self):
|
||||
if isinstance(self.max_key_fee, dict):
|
||||
max_fee = LBRYFeeValidator(self.max_key_fee)
|
||||
max_fee = FeeValidator(self.max_key_fee)
|
||||
if max_fee.currency_symbol == "LBC":
|
||||
return max_fee.amount
|
||||
return self.exchange_rate_manager.to_lbc(self.fee).amount
|
||||
|
@ -105,7 +105,7 @@ class GetStream(object):
|
|||
|
||||
def get_downloader_factory(metadata):
|
||||
for factory in metadata.factories:
|
||||
if isinstance(factory, ManagedLBRYFileDownloaderFactory):
|
||||
if isinstance(factory, ManagedEncryptedFileDownloaderFactory):
|
||||
return factory, metadata
|
||||
raise Exception('No suitable factory was found in {}'.format(metadata.factories))
|
||||
|
||||
|
@ -123,7 +123,7 @@ class GetStream(object):
|
|||
self.stream_hash = self.stream_info['sources']['lbry_sd_hash']
|
||||
|
||||
if 'fee' in self.stream_info:
|
||||
self.fee = LBRYFeeValidator(self.stream_info['fee'])
|
||||
self.fee = FeeValidator(self.stream_info['fee'])
|
||||
max_key_fee = self._convert_max_fee()
|
||||
if self.exchange_rate_manager.to_lbc(self.fee).amount > max_key_fee:
|
||||
log.info("Key fee %f above limit of %f didn't download lbry://%s" % (self.fee.amount,
|
|
@ -6,7 +6,7 @@ import googlefinance
|
|||
from twisted.internet import defer, reactor
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
from lbrynet.metadata.LBRYFee import LBRYFeeValidator
|
||||
from lbrynet.metadata.Fee import FeeValidator
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -147,12 +147,12 @@ class ExchangeRateManager(object):
|
|||
def to_lbc(self, fee):
|
||||
if fee is None:
|
||||
return None
|
||||
if not isinstance(fee, LBRYFeeValidator):
|
||||
fee_in = LBRYFeeValidator(fee)
|
||||
if not isinstance(fee, FeeValidator):
|
||||
fee_in = FeeValidator(fee)
|
||||
else:
|
||||
fee_in = fee
|
||||
|
||||
return LBRYFeeValidator({fee_in.currency_symbol:
|
||||
return FeeValidator({fee_in.currency_symbol:
|
||||
{
|
||||
'amount': self.convert_currency(fee_in.currency_symbol, "LBC", fee_in.amount),
|
||||
'address': fee_in.address
|
||||
|
@ -202,12 +202,12 @@ class DummyExchangeRateManager(object):
|
|||
def to_lbc(self, fee):
|
||||
if fee is None:
|
||||
return None
|
||||
if not isinstance(fee, LBRYFeeValidator):
|
||||
fee_in = LBRYFeeValidator(fee)
|
||||
if not isinstance(fee, FeeValidator):
|
||||
fee_in = FeeValidator(fee)
|
||||
else:
|
||||
fee_in = fee
|
||||
|
||||
return LBRYFeeValidator({fee_in.currency_symbol:
|
||||
return FeeValidator({fee_in.currency_symbol:
|
||||
{
|
||||
'amount': self.convert_currency(fee_in.currency_symbol, "LBC", fee_in.amount),
|
||||
'address': fee_in.address
|
|
@ -7,11 +7,11 @@ import random
|
|||
from appdirs import user_data_dir
|
||||
|
||||
from lbrynet.core.Error import InsufficientFundsError
|
||||
from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfilemanager.EncryptedFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.metadata.LBRYMetadata import Metadata
|
||||
from lbrynet.lbryfilemanager.LBRYFileDownloader import ManagedLBRYFileDownloader
|
||||
from lbrynet.metadata.Metadata import Metadata
|
||||
from lbrynet.lbryfilemanager.EncryptedFileDownloader import ManagedEncryptedFileDownloader
|
||||
from lbrynet import reflector
|
||||
from lbrynet.conf import LOG_FILE_NAME, REFLECTOR_SERVERS
|
||||
from twisted.internet import threads, defer, reactor
|
||||
|
@ -124,7 +124,7 @@ class Publisher(object):
|
|||
|
||||
def set_status(self):
|
||||
log.debug('Setting status')
|
||||
d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedLBRYFileDownloader.STATUS_FINISHED)
|
||||
d = self.lbry_file_manager.change_lbry_file_status(self.lbry_file, ManagedEncryptedFileDownloader.STATUS_FINISHED)
|
||||
d.addCallback(lambda _: self.lbry_file.restore())
|
||||
return d
|
||||
|
|
@ -27,7 +27,7 @@ lbrynet_log = os.path.join(log_dir, LOG_FILE_NAME)
|
|||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class LBRYUIManager(object):
|
||||
class UIManager(object):
|
||||
def __init__(self, root):
|
||||
if sys.platform != "darwin":
|
||||
self.data_dir = os.path.join(os.path.expanduser("~"), '.lbrynet')
|
|
@ -80,7 +80,7 @@ class USDFeeValidator(Validator):
|
|||
Validator.__init__(self, fee)
|
||||
|
||||
|
||||
class LBRYFeeValidator(Validator):
|
||||
class FeeValidator(Validator):
|
||||
CV001 = "0.0.1"
|
||||
CURRENT_CURRENCY_VERSION = CV001
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
|
||||
from lbrynet.metadata.Validator import Validator, skip_validate
|
||||
from lbrynet.metadata.LBRYFee import LBRYFeeValidator, verify_supported_currency
|
||||
from lbrynet.metadata.Fee import FeeValidator, verify_supported_currency
|
||||
from lbrynet.conf import SOURCE_TYPES
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -83,4 +83,4 @@ class Metadata(Validator):
|
|||
|
||||
def _load_fee(self):
|
||||
if 'fee' in self:
|
||||
self.update({'fee': LBRYFeeValidator(self['fee'])})
|
||||
self.update({'fee': FeeValidator(self['fee'])})
|
|
@ -1,3 +1,3 @@
|
|||
from lbrynet.reflector.server.server import ReflectorServerFactory as ServerFactory
|
||||
from lbrynet.reflector.client.client import LBRYFileReflectorClientFactory as ClientFactory
|
||||
from lbrynet.reflector.client.client import LBRYBlobReflectorClientFactory as BlobClientFactory
|
||||
from lbrynet.reflector.client.client import EncryptedFileReflectorClientFactory as ClientFactory
|
||||
from lbrynet.reflector.client.client import BlobReflectorClientFactory as BlobClientFactory
|
||||
|
|
|
@ -61,7 +61,7 @@ class IncompleteResponseError(Exception):
|
|||
pass
|
||||
|
||||
|
||||
class LBRYFileReflectorClient(Protocol):
|
||||
class EncryptedFileReflectorClient(Protocol):
|
||||
|
||||
# Protocol stuff
|
||||
|
||||
|
@ -238,8 +238,8 @@ class LBRYFileReflectorClient(Protocol):
|
|||
self.transport.loseConnection()
|
||||
|
||||
|
||||
class LBRYFileReflectorClientFactory(ClientFactory):
|
||||
protocol = LBRYFileReflectorClient
|
||||
class EncryptedFileReflectorClientFactory(ClientFactory):
|
||||
protocol = EncryptedFileReflectorClient
|
||||
|
||||
def __init__(self, blob_manager, stream_info_manager, stream_hash):
|
||||
self.blob_manager = blob_manager
|
||||
|
@ -269,7 +269,7 @@ class LBRYFileReflectorClientFactory(ClientFactory):
|
|||
log.debug("connection failed: %s", reason)
|
||||
|
||||
|
||||
class LBRYBlobReflectorClient(Protocol):
|
||||
class BlobReflectorClient(Protocol):
|
||||
# Protocol stuff
|
||||
|
||||
def connectionMade(self):
|
||||
|
@ -424,8 +424,8 @@ class LBRYBlobReflectorClient(Protocol):
|
|||
self.transport.loseConnection()
|
||||
|
||||
|
||||
class LBRYBlobReflectorClientFactory(ClientFactory):
|
||||
protocol = LBRYBlobReflectorClient
|
||||
class BlobReflectorClientFactory(ClientFactory):
|
||||
protocol = BlobReflectorClient
|
||||
|
||||
def __init__(self, blob_manager, blobs):
|
||||
self.blob_manager = blob_manager
|
||||
|
|
10
setup.py
10
setup.py
|
@ -57,9 +57,9 @@ console_scripts = [
|
|||
# 'lbrynet-rpc-node-cli = lbrynet.node_rpc_cli:main',
|
||||
# 'lbrynet-lookup-hosts-for-hash = lbrynet.dht_scripts:get_hosts_for_hash_in_dht',
|
||||
# 'lbrynet-announce_hash_to_dht = lbrynet.dht_scripts:announce_hash_to_dht',
|
||||
'lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:start',
|
||||
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.LBRYDaemonControl:stop',
|
||||
'lbrynet-cli = lbrynet.lbrynet_daemon.LBRYDaemonCLI:main'
|
||||
'lbrynet-daemon = lbrynet.lbrynet_daemon.DaemonControl:start',
|
||||
'stop-lbrynet-daemon = lbrynet.lbrynet_daemon.DaemonControl:stop',
|
||||
'lbrynet-cli = lbrynet.lbrynet_daemon.DaemonCLI:main'
|
||||
]
|
||||
|
||||
if platform == LINUX:
|
||||
|
@ -303,7 +303,7 @@ elif platform == WINDOWS:
|
|||
)
|
||||
|
||||
daemon_exe = Executable(
|
||||
script=os.path.join(daemon_dir, 'LBRYDaemonControl.py'),
|
||||
script=os.path.join(daemon_dir, 'DaemonControl.py'),
|
||||
icon=win_icon,
|
||||
# shortcutName="lbrynet-daemon",
|
||||
# shortcutDir='DesktopFolder',
|
||||
|
@ -311,7 +311,7 @@ elif platform == WINDOWS:
|
|||
)
|
||||
|
||||
cli_exe = Executable(
|
||||
script=os.path.join(daemon_dir, 'LBRYDaemonCLI.py'),
|
||||
script=os.path.join(daemon_dir, 'DaemonCLI.py'),
|
||||
icon=win_icon,
|
||||
# shortcutName="lbrynet-cli",
|
||||
# shortcutDir='DesktopFolder',
|
||||
|
|
|
@ -16,17 +16,17 @@ from lbrynet.lbrylive.PaymentRateManager import BaseLiveStreamPaymentRateManager
|
|||
from lbrynet.lbrylive.PaymentRateManager import LiveStreamPaymentRateManager
|
||||
from lbrynet.lbrylive.LiveStreamMetadataManager import DBLiveStreamMetadataManager
|
||||
from lbrynet.lbrylive.LiveStreamMetadataManager import TempLiveStreamMetadataManager
|
||||
from lbrynet.lbryfile.LBRYFileMetadataManager import TempLBRYFileMetadataManager, DBLBRYFileMetadataManager
|
||||
from lbrynet.lbryfilemanager.LBRYFileManager import LBRYFileManager
|
||||
from lbrynet.lbryfile.EncryptedFileMetadataManager import TempEncryptedFileMetadataManager, DBEncryptedFileMetadataManager
|
||||
from lbrynet.lbryfilemanager.EncryptedFileManager import EncryptedFileManager
|
||||
from lbrynet.core.PaymentRateManager import PaymentRateManager
|
||||
from lbrynet.core.PTCWallet import PointTraderKeyQueryHandlerFactory, PointTraderKeyExchanger
|
||||
from lbrynet.core.Session import LBRYSession
|
||||
from lbrynet.core.Session import Session
|
||||
from lbrynet.core.client.StandaloneBlobDownloader import StandaloneBlobDownloader
|
||||
from lbrynet.core.StreamDescriptor import BlobStreamDescriptorWriter
|
||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier
|
||||
from lbrynet.core.StreamDescriptor import download_sd_blob
|
||||
from lbrynet.lbryfilemanager.LBRYFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfile.client.LBRYFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbryfilemanager.EncryptedFileCreator import create_lbry_file
|
||||
from lbrynet.lbryfile.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier
|
||||
from lbrynet.lbryfile.StreamDescriptor import get_sd_info
|
||||
from twisted.internet import defer, threads, task, error
|
||||
from twisted.trial.unittest import TestCase
|
||||
|
@ -41,7 +41,7 @@ from lbrynet.lbrylive.server.LiveBlobInfoQueryHandler import CryptBlobInfoQueryH
|
|||
from lbrynet.lbrylive.client.LiveStreamOptions import add_live_stream_to_sd_identifier
|
||||
from lbrynet.lbrylive.client.LiveStreamDownloader import add_full_live_stream_downloader_to_sd_identifier
|
||||
from lbrynet.core.BlobManager import TempBlobManager
|
||||
from lbrynet.reflector.client.client import LBRYFileReflectorClientFactory
|
||||
from lbrynet.reflector.client.client import EncryptedFileReflectorClientFactory
|
||||
from lbrynet.reflector.server.server import ReflectorServerFactory
|
||||
from lbrynet.lbryfile.StreamDescriptor import publish_sd_blob
|
||||
|
||||
|
@ -232,13 +232,13 @@ def start_lbry_uploader(sd_hash_queue, kill_event, dead_event, file_size, ul_rat
|
|||
db_dir = "server"
|
||||
os.mkdir(db_dir)
|
||||
|
||||
session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
stream_info_manager = TempLBRYFileMetadataManager()
|
||||
stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
|
||||
lbry_file_manager = LBRYFileManager(session, stream_info_manager, sd_identifier)
|
||||
lbry_file_manager = EncryptedFileManager(session, stream_info_manager, sd_identifier)
|
||||
|
||||
if ul_rate_limit is not None:
|
||||
session.rate_limiter.set_ul_limit(ul_rate_limit)
|
||||
|
@ -349,14 +349,14 @@ def start_lbry_reuploader(sd_hash, kill_event, dead_event, ready_event, n, ul_ra
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd" + str(n),
|
||||
session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd" + str(n),
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=None, peer_port=peer_port,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
stream_info_manager = TempLBRYFileMetadataManager()
|
||||
stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
|
||||
lbry_file_manager = LBRYFileManager(session, stream_info_manager, sd_identifier)
|
||||
lbry_file_manager = EncryptedFileManager(session, stream_info_manager, sd_identifier)
|
||||
|
||||
if ul_rate_limit is not None:
|
||||
session.rate_limiter.set_ul_limit(ul_rate_limit)
|
||||
|
@ -463,7 +463,7 @@ def start_live_server(sd_hash_queue, kill_event, dead_event):
|
|||
db_dir = "server"
|
||||
os.mkdir(db_dir)
|
||||
|
||||
session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
|
@ -608,7 +608,7 @@ def start_blob_uploader(blob_hash_queue, kill_event, dead_event, slow):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="efgh",
|
||||
session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="efgh",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=peer_port,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
@ -781,14 +781,14 @@ class TestTransfer(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
def make_downloader(metadata, prm):
|
||||
info_validator = metadata.validator
|
||||
|
@ -865,7 +865,7 @@ class TestTransfer(TestCase):
|
|||
db_dir = "client"
|
||||
os.mkdir(db_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer, blob_dir=None,
|
||||
peer_port=5553, use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
|
@ -969,7 +969,7 @@ class TestTransfer(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
@ -1049,14 +1049,14 @@ class TestTransfer(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=5553, use_upnp=False,
|
||||
rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
self.stream_info_manager = DBLBRYFileMetadataManager(self.session.db_dir)
|
||||
self.stream_info_manager = DBEncryptedFileMetadataManager(self.session.db_dir)
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
def make_downloader(metadata, prm):
|
||||
info_validator = metadata.validator
|
||||
|
@ -1165,14 +1165,14 @@ class TestTransfer(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=None, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
def start_additional_uploaders(sd_hash):
|
||||
for i in range(1, num_uploaders):
|
||||
|
@ -1283,14 +1283,14 @@ class TestStreamify(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
self.stream_info_manager = TempLBRYFileMetadataManager()
|
||||
self.stream_info_manager = TempEncryptedFileMetadataManager()
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
d = self.session.setup()
|
||||
d.addCallback(lambda _: self.stream_info_manager.setup())
|
||||
|
@ -1335,14 +1335,14 @@ class TestStreamify(TestCase):
|
|||
os.mkdir(db_dir)
|
||||
os.mkdir(blob_dir)
|
||||
|
||||
self.session = LBRYSession(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
self.session = Session(MIN_BLOB_DATA_PAYMENT_RATE, db_dir=db_dir, lbryid="abcd",
|
||||
peer_finder=peer_finder, hash_announcer=hash_announcer,
|
||||
blob_dir=blob_dir, peer_port=5553,
|
||||
use_upnp=False, rate_limiter=rate_limiter, wallet=wallet)
|
||||
|
||||
self.stream_info_manager = DBLBRYFileMetadataManager(self.session.db_dir)
|
||||
self.stream_info_manager = DBEncryptedFileMetadataManager(self.session.db_dir)
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
self.lbry_file_manager = EncryptedFileManager(self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
def start_lbry_file(lbry_file):
|
||||
logging.debug("Calling lbry_file.start()")
|
||||
|
|
|
@ -12,10 +12,10 @@ from lbrynet.core import PeerManager
|
|||
from lbrynet.core import RateLimiter
|
||||
from lbrynet.core import Session
|
||||
from lbrynet.core import StreamDescriptor
|
||||
from lbrynet.lbryfile import LBRYFileMetadataManager
|
||||
from lbrynet.lbryfile.client import LBRYFileOptions
|
||||
from lbrynet.lbryfilemanager import LBRYFileCreator
|
||||
from lbrynet.lbryfilemanager import LBRYFileManager
|
||||
from lbrynet.lbryfile import EncryptedFileMetadataManager
|
||||
from lbrynet.lbryfile.client import EncryptedFileOptions
|
||||
from lbrynet.lbryfilemanager import EncryptedFileCreator
|
||||
from lbrynet.lbryfilemanager import EncryptedFileManager
|
||||
|
||||
from tests import mocks
|
||||
|
||||
|
@ -81,7 +81,7 @@ class TestReflector(unittest.TestCase):
|
|||
db_dir = "client"
|
||||
os.mkdir(db_dir)
|
||||
|
||||
self.session = Session.LBRYSession(
|
||||
self.session = Session.Session(
|
||||
conf.MIN_BLOB_DATA_PAYMENT_RATE,
|
||||
db_dir=db_dir,
|
||||
lbryid="abcd",
|
||||
|
@ -94,16 +94,16 @@ class TestReflector(unittest.TestCase):
|
|||
wallet=wallet
|
||||
)
|
||||
|
||||
self.stream_info_manager = LBRYFileMetadataManager.TempLBRYFileMetadataManager()
|
||||
self.stream_info_manager = EncryptedFileMetadataManager.TempEncryptedFileMetadataManager()
|
||||
|
||||
self.lbry_file_manager = LBRYFileManager.LBRYFileManager(
|
||||
self.lbry_file_manager = EncryptedFileManager.EncryptedFileManager(
|
||||
self.session, self.stream_info_manager, sd_identifier)
|
||||
|
||||
self.server_blob_manager = BlobManager.TempBlobManager(hash_announcer)
|
||||
|
||||
d = self.session.setup()
|
||||
d.addCallback(lambda _: self.stream_info_manager.setup())
|
||||
d.addCallback(lambda _: LBRYFileOptions.add_lbry_file_to_sd_identifier(sd_identifier))
|
||||
d.addCallback(lambda _: EncryptedFileOptions.add_lbry_file_to_sd_identifier(sd_identifier))
|
||||
d.addCallback(lambda _: self.lbry_file_manager.setup())
|
||||
d.addCallback(lambda _: self.server_blob_manager.setup())
|
||||
|
||||
|
@ -128,7 +128,7 @@ class TestReflector(unittest.TestCase):
|
|||
|
||||
def create_stream():
|
||||
test_file = mocks.GenFile(5209343, b''.join([chr(i + 3) for i in xrange(0, 64, 6)]))
|
||||
d = LBRYFileCreator.create_lbry_file(
|
||||
d = EncryptedFileCreator.create_lbry_file(
|
||||
self.session,
|
||||
self.lbry_file_manager,
|
||||
"test_file",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import mock
|
||||
from lbrynet.metadata import LBRYMetadata
|
||||
from lbrynet.lbrynet_daemon import LBRYExchangeRateManager
|
||||
from lbrynet.metadata import Metadata
|
||||
from lbrynet.lbrynet_daemon import ExchangeRateManager
|
||||
|
||||
from twisted.trial import unittest
|
||||
|
||||
|
||||
class LBRYFeeFormatTest(unittest.TestCase):
|
||||
class FeeFormatTest(unittest.TestCase):
|
||||
def test_fee_created_with_correct_inputs(self):
|
||||
fee_dict = {
|
||||
'USD': {
|
||||
|
@ -13,11 +13,11 @@ class LBRYFeeFormatTest(unittest.TestCase):
|
|||
'address': "bRcHraa8bYJZL7vkh5sNmGwPDERFUjGPP9"
|
||||
}
|
||||
}
|
||||
fee = LBRYMetadata.LBRYFeeValidator(fee_dict)
|
||||
fee = Metadata.FeeValidator(fee_dict)
|
||||
self.assertEqual(10.0, fee['USD']['amount'])
|
||||
|
||||
|
||||
class LBRYFeeTest(unittest.TestCase):
|
||||
class FeeTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
patcher = mock.patch('time.time')
|
||||
self.time = patcher.start()
|
||||
|
@ -32,5 +32,5 @@ class LBRYFeeTest(unittest.TestCase):
|
|||
}
|
||||
}
|
||||
rates = {'BTCLBC': {'spot': 3.0, 'ts': 2}, 'USDBTC': {'spot': 2.0, 'ts': 3}}
|
||||
manager = LBRYExchangeRateManager.DummyExchangeRateManager(rates)
|
||||
manager = ExchangeRateManager.DummyExchangeRateManager(rates)
|
||||
self.assertEqual(60.0, manager.to_lbc(fee_dict).amount)
|
|
@ -1,4 +1,4 @@
|
|||
from lbrynet.metadata import LBRYMetadata
|
||||
from lbrynet.metadata import Metadata
|
||||
from twisted.trial import unittest
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ class MetadataTest(unittest.TestCase):
|
|||
def test_assertion_if_no_metadata(self):
|
||||
metadata = {}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata)
|
||||
Metadata.Metadata(metadata)
|
||||
|
||||
def test_assertion_if_source_is_missing(self):
|
||||
metadata = {
|
||||
|
@ -19,7 +19,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata)
|
||||
Metadata.Metadata(metadata)
|
||||
|
||||
def test_metadata_works_without_fee(self):
|
||||
metadata = {
|
||||
|
@ -33,7 +33,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'content-type': 'audio/mpeg',
|
||||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata)
|
||||
m = Metadata.Metadata(metadata)
|
||||
self.assertFalse('fee' in m)
|
||||
|
||||
def test_assertion_if_invalid_source(self):
|
||||
|
@ -49,7 +49,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata)
|
||||
Metadata.Metadata(metadata)
|
||||
|
||||
def test_assertion_if_missing_v001_field(self):
|
||||
metadata = {
|
||||
|
@ -64,7 +64,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg'
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata)
|
||||
Metadata.Metadata(metadata)
|
||||
|
||||
def test_version_is_001_if_all_fields_are_present(self):
|
||||
metadata = {
|
||||
|
@ -78,7 +78,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'content-type': 'audio/mpeg',
|
||||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
m = Metadata.Metadata(metadata, process_now=False)
|
||||
self.assertEquals('0.0.1', m.version)
|
||||
|
||||
def test_assertion_if_there_is_an_extra_field(self):
|
||||
|
@ -95,7 +95,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'MYSTERYFIELD': '?'
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
Metadata.Metadata(metadata, process_now=False)
|
||||
|
||||
def test_version_is_002_if_all_fields_are_present(self):
|
||||
metadata = {
|
||||
|
@ -112,7 +112,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'content-type': 'video/mp4',
|
||||
'thumbnail': 'https://svs.gsfc.nasa.gov/vis/a010000/a012000/a012034/Combined.00_08_16_17.Still004.jpg'
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
m = Metadata.Metadata(metadata, process_now=False)
|
||||
self.assertEquals('0.0.2', m.version)
|
||||
|
||||
def test_version_is_003_if_all_fields_are_present(self):
|
||||
|
@ -130,7 +130,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'content_type': 'video/mp4',
|
||||
'thumbnail': 'https://svs.gsfc.nasa.gov/vis/a010000/a012000/a012034/Combined.00_08_16_17.Still004.jpg'
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
m = Metadata.Metadata(metadata, process_now=False)
|
||||
self.assertEquals('0.0.3', m.version)
|
||||
|
||||
def test_version_claimed_is_001_but_version_is_002(self):
|
||||
|
@ -149,7 +149,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'thumbnail': 'https://svs.gsfc.nasa.gov/vis/a010000/a012000/a012034/Combined.00_08_16_17.Still004.jpg'
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
Metadata.Metadata(metadata, process_now=False)
|
||||
|
||||
def test_version_claimed_is_002_but_version_is_003(self):
|
||||
metadata = {
|
||||
|
@ -167,7 +167,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'thumbnail': 'https://svs.gsfc.nasa.gov/vis/a010000/a012000/a012034/Combined.00_08_16_17.Still004.jpg'
|
||||
}
|
||||
with self.assertRaises(AssertionError):
|
||||
LBRYMetadata.Metadata(metadata, process_now=False)
|
||||
Metadata.Metadata(metadata, process_now=False)
|
||||
|
||||
def test_version_001_ports_to_003(self):
|
||||
metadata = {
|
||||
|
@ -181,7 +181,7 @@ class MetadataTest(unittest.TestCase):
|
|||
'content-type': 'audio/mpeg',
|
||||
'thumbnail': 'http://ia.media-imdb.com/images/M/MV5BMTQwNjYzMTQ0Ml5BMl5BanBnXkFtZTcwNDUzODM5Nw@@._V1_SY1000_CR0,0,673,1000_AL_.jpg',
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata, process_now=True)
|
||||
m = Metadata.Metadata(metadata, process_now=True)
|
||||
self.assertEquals('0.0.3', m.version)
|
||||
|
||||
def test_version_002_ports_to_003(self):
|
||||
|
@ -199,5 +199,5 @@ class MetadataTest(unittest.TestCase):
|
|||
'content-type': 'video/mp4',
|
||||
'thumbnail': 'https://svs.gsfc.nasa.gov/vis/a010000/a012000/a012034/Combined.00_08_16_17.Still004.jpg'
|
||||
}
|
||||
m = LBRYMetadata.Metadata(metadata, process_now=True)
|
||||
m = Metadata.Metadata(metadata, process_now=True)
|
||||
self.assertEquals('0.0.3', m.version)
|
|
@ -2,7 +2,7 @@ import mock
|
|||
import requests
|
||||
from twisted.trial import unittest
|
||||
|
||||
from lbrynet.lbrynet_daemon import LBRYDaemon
|
||||
from lbrynet.lbrynet_daemon import Daemon
|
||||
|
||||
|
||||
class MiscTests(unittest.TestCase):
|
||||
|
@ -18,9 +18,9 @@ class MiscTests(unittest.TestCase):
|
|||
"tag_name": "v0.3.8",
|
||||
"prerelease": False
|
||||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.LBRYDaemon.requests') as req:
|
||||
with mock.patch('lbrynet.lbrynet_daemon.Daemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
self.assertEqual('0.3.8', LBRYDaemon.get_lbrynet_version_from_github())
|
||||
self.assertEqual('0.3.8', Daemon.get_lbrynet_version_from_github())
|
||||
|
||||
def test_error_is_thrown_if_prerelease(self):
|
||||
response = mock.create_autospec(requests.Response)
|
||||
|
@ -28,11 +28,11 @@ class MiscTests(unittest.TestCase):
|
|||
"tag_name": "v0.3.8",
|
||||
"prerelease": True
|
||||
}
|
||||
with mock.patch('lbrynet.lbrynet_daemon.LBRYDaemon.requests') as req:
|
||||
with mock.patch('lbrynet.lbrynet_daemon.Daemon.requests') as req:
|
||||
req.get.return_value = response
|
||||
with self.assertRaises(Exception):
|
||||
LBRYDaemon.get_lbrynet_version_from_github()
|
||||
Daemon.get_lbrynet_version_from_github()
|
||||
|
||||
def test_error_is_thrown_when_version_cant_be_parsed(self):
|
||||
with self.assertRaises(Exception):
|
||||
LBRYDaemon.get_version_from_tag('garbage')
|
||||
Daemon.get_version_from_tag('garbage')
|
|
@ -1,14 +1,14 @@
|
|||
from twisted.trial import unittest
|
||||
from lbrynet.lbrynet_daemon import LBRYDaemonCLI
|
||||
from lbrynet.lbrynet_daemon import DaemonCLI
|
||||
|
||||
|
||||
class LBRYDaemonCLITests(unittest.TestCase):
|
||||
class DaemonCLITests(unittest.TestCase):
|
||||
def test_guess_type(self):
|
||||
self.assertEqual('0.3.8', LBRYDaemonCLI.guess_type('0.3.8'))
|
||||
self.assertEqual(0.3, LBRYDaemonCLI.guess_type('0.3'))
|
||||
self.assertEqual(3, LBRYDaemonCLI.guess_type('3'))
|
||||
self.assertEqual('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA==', LBRYDaemonCLI.guess_type('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA=='))
|
||||
self.assertEqual(0.3, LBRYDaemonCLI.guess_type('0.3'))
|
||||
self.assertEqual('0.3.8', DaemonCLI.guess_type('0.3.8'))
|
||||
self.assertEqual(0.3, DaemonCLI.guess_type('0.3'))
|
||||
self.assertEqual(3, DaemonCLI.guess_type('3'))
|
||||
self.assertEqual('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA==', DaemonCLI.guess_type('VdNmakxFORPSyfCprAD/eDDPk5TY9QYtSA=='))
|
||||
self.assertEqual(0.3, DaemonCLI.guess_type('0.3'))
|
||||
|
||||
def test_get_params(self):
|
||||
test_params = [
|
||||
|
@ -25,4 +25,4 @@ class LBRYDaemonCLITests(unittest.TestCase):
|
|||
'n': 5,
|
||||
'address': 'bY13xeAjLrsjP4KGETwStK2a9UgKgXVTXu'
|
||||
}
|
||||
self.assertDictEqual(test_r, LBRYDaemonCLI.get_params_from_kwargs(test_params))
|
||||
self.assertDictEqual(test_r, DaemonCLI.get_params_from_kwargs(test_params))
|
Loading…
Reference in a new issue