From 6f71a5003cd469a3b953320a38cfb645978f8731 Mon Sep 17 00:00:00 2001 From: Jack Robison Date: Wed, 13 Sep 2017 16:42:17 -0400 Subject: [PATCH] remove unused EncryptedFileOpener --- lbrynet/daemon/Daemon.py | 14 +-- .../client/EncryptedFileDownloader.py | 87 ------------------- 2 files changed, 2 insertions(+), 99 deletions(-) diff --git a/lbrynet/daemon/Daemon.py b/lbrynet/daemon/Daemon.py index 8eb218fd3..a91c008f0 100644 --- a/lbrynet/daemon/Daemon.py +++ b/lbrynet/daemon/Daemon.py @@ -29,7 +29,6 @@ from lbrynet.reflector import reupload from lbrynet.reflector import ServerFactory as reflector_server_factory from lbrynet.core.log_support import configure_loggly_handler from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileSaverFactory -from lbrynet.lbry_file.client.EncryptedFileDownloader import EncryptedFileOpenerFactory from lbrynet.lbry_file.client.EncryptedFileOptions import add_lbry_file_to_sd_identifier from lbrynet.lbry_file.EncryptedFileMetadataManager import DBEncryptedFileMetadataManager from lbrynet.lbry_file.StreamDescriptor import EncryptedFileStreamType @@ -578,17 +577,8 @@ class Daemon(AuthJSONRPCServer): self.session.wallet, self.download_directory ) - 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( - EncryptedFileStreamType, file_opener_factory) + self.sd_identifier.add_stream_downloader_factory(EncryptedFileStreamType, + file_saver_factory) return defer.succeed(None) def _download_blob(self, blob_hash, rate_manager=None, timeout=None): diff --git a/lbrynet/lbry_file/client/EncryptedFileDownloader.py b/lbrynet/lbry_file/client/EncryptedFileDownloader.py index e18c6f2cf..1ba7a9533 100644 --- a/lbrynet/lbry_file/client/EncryptedFileDownloader.py +++ b/lbrynet/lbry_file/client/EncryptedFileDownloader.py @@ -282,90 +282,3 @@ class EncryptedFileSaverFactory(EncryptedFileDownloaderFactory): @staticmethod def get_description(): return "Save" - - -class EncryptedFileOpener(EncryptedFileDownloader): - def __init__(self, stream_hash, peer_finder, rate_limiter, blob_manager, stream_info_manager, - payment_rate_manager, wallet): - EncryptedFileDownloader.__init__(self, stream_hash, - peer_finder, rate_limiter, - blob_manager, stream_info_manager, - payment_rate_manager, wallet, - ) - self.process = None - self.process_log = None - - def stop(self, err=None): - d = EncryptedFileDownloader.stop(self, err=err) - d.addCallback(lambda _: self._delete_from_info_manager()) - return d - - def _get_progress_manager(self, download_manager): - return FullStreamProgressManager(self._finished_downloading, - self.blob_manager, - download_manager) - - def _setup_output(self): - def start_process(): - if os.name == "nt": - paths = [r'C:\Program Files\VideoLAN\VLC\vlc.exe', - r'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe'] - for p in paths: - if os.path.exists(p): - vlc_path = p - break - else: - raise ValueError("You must install VLC media player to stream files") - else: - vlc_path = 'vlc' - self.process_log = open("vlc.out", 'a') - try: - self.process = subprocess.Popen([vlc_path, '-'], stdin=subprocess.PIPE, - stdout=self.process_log, stderr=self.process_log) - except OSError: - raise ValueError("VLC media player could not be opened") - - d = threads.deferToThread(start_process) - return d - - def _close_output(self): - if self.process is not None: - self.process.stdin.close() - self.process = None - return defer.succeed(True) - - def _get_write_func(self): - def write_func(data): - if self.stopped is False and self.process is not None: - try: - self.process.stdin.write(data) - except IOError: - reactor.callLater(0, self.stop) - return write_func - - def _delete_from_info_manager(self): - return self.stream_info_manager.delete_stream(self.stream_hash) - - -class EncryptedFileOpenerFactory(EncryptedFileDownloaderFactory): - def can_download(self, sd_validator): - if which('vlc'): - return True - elif os.name == "nt": - paths = [r'C:\Program Files\VideoLAN\VLC\vlc.exe', - r'C:\Program Files (x86)\VideoLAN\VLC\vlc.exe'] - for p in paths: - if os.path.exists(p): - return True - return False - - def _make_downloader(self, stream_hash, payment_rate_manager, stream_info): - return EncryptedFileOpener(stream_hash, self.peer_finder, - self.rate_limiter, self.blob_manager, - self.stream_info_manager, - payment_rate_manager, self.wallet, - ) - - @staticmethod - def get_description(): - return "Stream"