Clean up legacy code

This commit is contained in:
Zestyr 2017-07-03 20:29:58 +02:00
parent 21de1fceee
commit a2350fd539
4 changed files with 4 additions and 36 deletions

View file

@ -56,7 +56,6 @@ class GetStream(object):
# fired after the metadata and the first data blob have been downloaded # fired after the metadata and the first data blob have been downloaded
self.data_downloading_deferred = defer.Deferred(None) self.data_downloading_deferred = defer.Deferred(None)
@property @property
def download_path(self): def download_path(self):
return os.path.join(self.download_directory, self.downloader.file_name) return os.path.join(self.download_directory, self.downloader.file_name)
@ -211,4 +210,3 @@ class GetStream(object):
raise raise
defer.returnValue((self.downloader, self.finished_deferred)) defer.returnValue((self.downloader, self.finished_deferred))

View file

@ -1,24 +1,14 @@
import logging import logging
import os
import sys
import mimetypes import mimetypes
from appdirs import user_data_dir
from zope.interface import implements from zope.interface import implements
from twisted.internet import defer, error, interfaces, abstract, task, reactor from twisted.internet import defer, error, interfaces, abstract, task, reactor
# TODO: omg, this code is essentially duplicated in Daemon
if sys.platform != "darwin":
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
data_dir = user_data_dir("LBRY")
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
STATUS_FINISHED = 'finished' STATUS_FINISHED = 'finished'
class EncryptedFileStreamer(object): class EncryptedFileStreamer(object):
""" """
Writes LBRY stream to request; will pause to wait for new data if the file Writes LBRY stream to request; will pause to wait for new data if the file
@ -31,7 +21,6 @@ class EncryptedFileStreamer(object):
bufferSize = abstract.FileDescriptor.bufferSize bufferSize = abstract.FileDescriptor.bufferSize
# How long to wait between sending blocks (needed because some # How long to wait between sending blocks (needed because some
# video players freeze up if you try to send data too fast) # video players freeze up if you try to send data too fast)
stream_interval = 0.005 stream_interval = 0.005
@ -39,7 +28,6 @@ class EncryptedFileStreamer(object):
# How long to wait before checking if new data has been appended to the file # How long to wait before checking if new data has been appended to the file
new_data_check_interval = 0.25 new_data_check_interval = 0.25
def __init__(self, request, path, stream, file_manager): def __init__(self, request, path, stream, file_manager):
def _set_content_length_header(length): def _set_content_length_header(length):
self._request.setHeader('content-length', length) self._request.setHeader('content-length', length)

View file

@ -2,26 +2,15 @@ import logging
import os import os
import shutil import shutil
import json import json
import sys
import tempfile import tempfile
from appdirs import user_data_dir
from twisted.web import server, static, resource from twisted.web import server, static, resource
from twisted.internet import defer, error from twisted.internet import defer, error
from lbrynet import conf from lbrynet import conf
from lbrynet.daemon.FileStreamer import EncryptedFileStreamer from lbrynet.daemon.FileStreamer import EncryptedFileStreamer
# TODO: omg, this code is essentially duplicated in Daemon
if sys.platform != "darwin":
data_dir = os.path.join(os.path.expanduser("~"), ".lbrynet")
else:
data_dir = user_data_dir("LBRY")
if not os.path.isdir(data_dir):
os.mkdir(data_dir)
log = logging.getLogger(__name__) log = logging.getLogger(__name__)

View file

@ -1,21 +1,14 @@
import json import json
import logging.handlers import logging.handlers
import sys
import os import os
from appdirs import user_data_dir
from twisted.internet.task import LoopingCall from twisted.internet.task import LoopingCall
from twisted.internet import reactor from twisted.internet import reactor
from lbrynet import conf
if sys.platform != "darwin": conf.initialize_settings()
log_dir = os.path.join(os.path.expanduser("~"), ".lbrynet") log_dir = conf.settings['data_dir']
else:
log_dir = user_data_dir("LBRY")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log') LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
if os.path.isfile(LOG_FILENAME): if os.path.isfile(LOG_FILENAME):