Merge pull request #234 from lbryio/unicode-settings

download directory and ui bug fixes for windows
This commit is contained in:
Job Evers‐Meltzer 2016-11-02 07:19:51 -05:00 committed by GitHub
commit b316b56885
4 changed files with 16 additions and 13 deletions

View file

@ -64,6 +64,8 @@ def _convert_setting(env_val, current_val):
return float(env_val)
elif current_type is str:
return str(env_val)
elif current_type is unicode:
return unicode(env_val)
elif current_type is dict:
return dict(env_val)
elif current_type is list:

View file

@ -1,7 +1,6 @@
import os
import logging
import shutil
import sys
import json
from urllib2 import urlopen
@ -13,7 +12,6 @@ from lbrynet.lbrynet_daemon.Resources import NoCacheStaticFile
from lbrynet import __version__ as lbrynet_version
from lbryum.version import LBRYUM_VERSION as lbryum_version
from zipfile import ZipFile
from appdirs import user_data_dir
log = logging.getLogger(__name__)
@ -21,17 +19,10 @@ log = logging.getLogger(__name__)
class UIManager(object):
def __init__(self, root):
if sys.platform != "darwin":
self.data_dir = os.path.join(os.path.expanduser("~"), '.lbrynet')
else:
self.data_dir = user_data_dir("LBRY")
self.ui_root = os.path.join(self.data_dir, "lbry-ui")
self.ui_root = os.path.join(settings.data_dir, "lbry-ui")
self.active_dir = os.path.join(self.ui_root, "active")
self.update_dir = os.path.join(self.ui_root, "update")
if not os.path.isdir(self.data_dir):
os.mkdir(self.data_dir)
if not os.path.isdir(self.ui_root):
os.mkdir(self.ui_root)
if not os.path.isdir(self.active_dir):

View file

@ -99,7 +99,7 @@ class EncryptedFileReflectorClient(Protocol):
log.debug('Finished sending data via reflector')
self.factory.finished_deferred.callback(True)
else:
log.debug('reflector finished: %s', reason)
log.debug('Reflector finished: %s', reason)
self.factory.finished_deferred.callback(reason)
# IConsumer stuff
@ -407,6 +407,10 @@ class BlobReflectorClient(Protocol):
'blob_size': self.next_blob_to_send.length
}))
def log_fail_and_disconnect(self, err, blob_hash):
log.error("Error reflecting blob %s", blob_hash)
self.transport.loseConnection()
def send_next_request(self):
if self.file_sender is not None:
# send the blob
@ -420,7 +424,7 @@ class BlobReflectorClient(Protocol):
d = self.blob_manager.get_blob(blob_hash, True)
d.addCallback(self.open_blob_for_reading)
# send the server the next blob hash + length
d.addCallback(lambda _: self.send_blob_info())
d.addCallbacks(lambda _: self.send_blob_info(), lambda err: self.log_fail_and_disconnect(err, blob_hash))
return d
else:
# close connection

View file

@ -39,7 +39,13 @@ def _reflect_if_unavailable(reflector_has_stream, lbry_file, reflector_server):
return _reflect_stream(lbry_file, reflector_server)
def _catch_error(err, uri):
log.error("An error occurred while checking availability for lbry://%s", uri)
log.debug("Traceback: %s", err.getTraceback())
def check_and_restore_availability(lbry_file, reflector_server):
d = _check_if_reflector_has_stream(lbry_file, reflector_server)
d.addCallback(lambda send_stream: _reflect_if_unavailable(send_stream, lbry_file, reflector_server))
d.addCallbacks(lambda send_stream: _reflect_if_unavailable(send_stream, lbry_file, reflector_server),
lambda err: _catch_error(err, lbry_file.uri))
return d