Merge branch 'master' of https://github.com/jleute/lbry
This commit is contained in:
commit
c1fae45de6
4 changed files with 52 additions and 8 deletions
|
@ -19,6 +19,7 @@ at anytime.
|
||||||
* `use_auth_http` in a config file being overridden by the default command line argument to `lbrynet-daemon`, now the command line value will only override the config file value if it is provided
|
* `use_auth_http` in a config file being overridden by the default command line argument to `lbrynet-daemon`, now the command line value will only override the config file value if it is provided
|
||||||
* `lbrynet-cli` not automatically switching to the authenticated client if the server is detected to be using authentication. This resulted in `lbrynet-cli` failing to run when `lbrynet-daemon` was run with the `--http-auth` flag
|
* `lbrynet-cli` not automatically switching to the authenticated client if the server is detected to be using authentication. This resulted in `lbrynet-cli` failing to run when `lbrynet-daemon` was run with the `--http-auth` flag
|
||||||
* fixed error when using `claim_show` with `txid` and `nout` arguments
|
* fixed error when using `claim_show` with `txid` and `nout` arguments
|
||||||
|
* fixed error when saving server list to conf file (issue #1109)
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
*
|
*
|
||||||
|
|
|
@ -168,6 +168,8 @@ def server_port(server_and_port):
|
||||||
def server_list(servers):
|
def server_list(servers):
|
||||||
return [server_port(server) for server in servers]
|
return [server_port(server) for server in servers]
|
||||||
|
|
||||||
|
def server_list_reverse(servers):
|
||||||
|
return ["%s:%s" % (server, port) for server, port in servers]
|
||||||
|
|
||||||
class Env(envparse.Env):
|
class Env(envparse.Env):
|
||||||
"""An Env parser that automatically namespaces the variables with LBRY"""
|
"""An Env parser that automatically namespaces the variables with LBRY"""
|
||||||
|
@ -267,7 +269,7 @@ ADJUSTABLE_SETTINGS = {
|
||||||
'is_generous_host': (bool, True),
|
'is_generous_host': (bool, True),
|
||||||
'announce_head_blobs_only': (bool, True),
|
'announce_head_blobs_only': (bool, True),
|
||||||
'concurrent_announcers': (int, DEFAULT_CONCURRENT_ANNOUNCERS),
|
'concurrent_announcers': (int, DEFAULT_CONCURRENT_ANNOUNCERS),
|
||||||
'known_dht_nodes': (list, DEFAULT_DHT_NODES, server_list),
|
'known_dht_nodes': (list, DEFAULT_DHT_NODES, server_list, server_list_reverse),
|
||||||
'lbryum_wallet_dir': (str, default_lbryum_dir),
|
'lbryum_wallet_dir': (str, default_lbryum_dir),
|
||||||
'max_connections_per_stream': (int, 5),
|
'max_connections_per_stream': (int, 5),
|
||||||
'seek_head_blob_first': (bool, True),
|
'seek_head_blob_first': (bool, True),
|
||||||
|
@ -285,7 +287,7 @@ ADJUSTABLE_SETTINGS = {
|
||||||
# event the initial upload failed or was disconnected part way through, provided the auto_re_reflect_interval > 0)
|
# event the initial upload failed or was disconnected part way through, provided the auto_re_reflect_interval > 0)
|
||||||
'reflect_uploads': (bool, True),
|
'reflect_uploads': (bool, True),
|
||||||
'auto_re_reflect_interval': (int, 86400), # set to 0 to disable
|
'auto_re_reflect_interval': (int, 86400), # set to 0 to disable
|
||||||
'reflector_servers': (list, [('reflector2.lbry.io', 5566)], server_list),
|
'reflector_servers': (list, [('reflector2.lbry.io', 5566)], server_list, server_list_reverse),
|
||||||
'run_reflector_server': (bool, False),
|
'run_reflector_server': (bool, False),
|
||||||
'sd_download_timeout': (int, 3),
|
'sd_download_timeout': (int, 3),
|
||||||
'share_usage_data': (bool, True), # whether to share usage stats and diagnostic info with LBRY
|
'share_usage_data': (bool, True), # whether to share usage stats and diagnostic info with LBRY
|
||||||
|
@ -295,7 +297,8 @@ ADJUSTABLE_SETTINGS = {
|
||||||
'use_keyring': (bool, False),
|
'use_keyring': (bool, False),
|
||||||
'wallet': (str, LBRYUM_WALLET),
|
'wallet': (str, LBRYUM_WALLET),
|
||||||
'blockchain_name': (str, 'lbrycrd_main'),
|
'blockchain_name': (str, 'lbrycrd_main'),
|
||||||
'lbryum_servers': (list, [('lbryum8.lbry.io', 50001), ('lbryum9.lbry.io', 50001)], server_list),
|
'lbryum_servers': (list, [('lbryum8.lbry.io', 50001), ('lbryum9.lbry.io',
|
||||||
|
50001)], server_list, server_list_reverse),
|
||||||
's3_headers_depth': (int, 96 * 10) # download headers from s3 when the local height is more than 10 chunks behind
|
's3_headers_depth': (int, 96 * 10) # download headers from s3 when the local height is more than 10 chunks behind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,18 +500,30 @@ class Config(object):
|
||||||
path = conf_file
|
path = conf_file
|
||||||
else:
|
else:
|
||||||
path = self.get_conf_filename()
|
path = self.get_conf_filename()
|
||||||
|
# reverse the conversions done after loading the settings from the conf
|
||||||
|
# file
|
||||||
|
rev = self._convert_conf_file_lists_reverse(self._data[TYPE_PERSISTED])
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
encoder = settings_encoders.get(ext, False)
|
encoder = settings_encoders.get(ext, False)
|
||||||
assert encoder is not False, 'Unknown settings format %s' % ext
|
assert encoder is not False, 'Unknown settings format %s' % ext
|
||||||
with open(path, 'w') as settings_file:
|
with open(path, 'w') as settings_file:
|
||||||
settings_file.write(encoder(self._data[TYPE_PERSISTED]))
|
settings_file.write(encoder(rev))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _convert_conf_file_lists_reverse(converted):
|
||||||
|
rev = {}
|
||||||
|
for k in converted.iterkeys():
|
||||||
|
if k in ADJUSTABLE_SETTINGS and len(ADJUSTABLE_SETTINGS[k]) == 4:
|
||||||
|
rev[k] = ADJUSTABLE_SETTINGS[k][3](converted[k])
|
||||||
|
else:
|
||||||
|
rev[k] = converted[k]
|
||||||
|
return rev
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _convert_conf_file_lists(decoded):
|
def _convert_conf_file_lists(decoded):
|
||||||
converted = {}
|
converted = {}
|
||||||
for k, v in decoded.iteritems():
|
for k, v in decoded.iteritems():
|
||||||
if k in ADJUSTABLE_SETTINGS and len(ADJUSTABLE_SETTINGS[k]) == 3:
|
if k in ADJUSTABLE_SETTINGS and len(ADJUSTABLE_SETTINGS[k]) >= 3:
|
||||||
converted[k] = ADJUSTABLE_SETTINGS[k][2](v)
|
converted[k] = ADJUSTABLE_SETTINGS[k][2](v)
|
||||||
else:
|
else:
|
||||||
converted[k] = v
|
converted[k] = v
|
||||||
|
@ -523,7 +538,6 @@ class Config(object):
|
||||||
path = conf_file
|
path = conf_file
|
||||||
else:
|
else:
|
||||||
path = self.get_conf_filename()
|
path = self.get_conf_filename()
|
||||||
|
|
||||||
ext = os.path.splitext(path)[1]
|
ext = os.path.splitext(path)[1]
|
||||||
decoder = settings_decoders.get(ext, False)
|
decoder = settings_decoders.get(ext, False)
|
||||||
assert decoder is not False, 'Unknown settings format %s' % ext
|
assert decoder is not False, 'Unknown settings format %s' % ext
|
||||||
|
@ -630,6 +644,8 @@ def get_default_env():
|
||||||
for k, v in ADJUSTABLE_SETTINGS.iteritems():
|
for k, v in ADJUSTABLE_SETTINGS.iteritems():
|
||||||
if len(v) == 3:
|
if len(v) == 3:
|
||||||
env_defaults[k] = (v[0], None, v[2])
|
env_defaults[k] = (v[0], None, v[2])
|
||||||
|
elif len(v) == 4:
|
||||||
|
env_defaults[k] = (v[0], None, v[2], v[3])
|
||||||
else:
|
else:
|
||||||
env_defaults[k] = (v[0], None)
|
env_defaults[k] = (v[0], None)
|
||||||
return Env(**env_defaults)
|
return Env(**env_defaults)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
import tempfile
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from lbrynet import conf
|
from lbrynet import conf
|
||||||
from lbrynet.core.Error import InvalidCurrencyError
|
from lbrynet.core.Error import InvalidCurrencyError
|
||||||
|
@ -77,3 +78,30 @@ class SettingsTest(unittest.TestCase):
|
||||||
self.assertEqual(str, type(conf.default_download_dir))
|
self.assertEqual(str, type(conf.default_download_dir))
|
||||||
self.assertEqual(str, type(conf.default_data_dir))
|
self.assertEqual(str, type(conf.default_data_dir))
|
||||||
self.assertEqual(str, type(conf.default_lbryum_dir))
|
self.assertEqual(str, type(conf.default_lbryum_dir))
|
||||||
|
|
||||||
|
def test_load_save_config_file(self):
|
||||||
|
# setup settings
|
||||||
|
adjustable_settings = {'data_dir': (str, conf.default_data_dir),
|
||||||
|
'lbryum_servers': (list, [('localhost', 5001)],
|
||||||
|
conf.server_list, conf.server_list_reverse)}
|
||||||
|
env = conf.Env(**adjustable_settings)
|
||||||
|
settings = conf.Config({}, adjustable_settings, environment=env)
|
||||||
|
conf.settings = settings
|
||||||
|
# setup tempfile
|
||||||
|
conf_entry = "lbryum_servers: ['localhost:50001', 'localhost:50002']\n"
|
||||||
|
with tempfile.NamedTemporaryFile(suffix='.yml') as conf_file:
|
||||||
|
conf_file.write(conf_entry)
|
||||||
|
conf_file.seek(0)
|
||||||
|
conf.conf_file = conf_file.name
|
||||||
|
# load and save settings from conf file
|
||||||
|
settings.load_conf_file_settings()
|
||||||
|
settings.save_conf_file_settings()
|
||||||
|
# test if overwritten entry equals original entry
|
||||||
|
# use decoded versions, because format might change without
|
||||||
|
# changing the interpretation
|
||||||
|
decoder = conf.settings_decoders['.yml']
|
||||||
|
conf_decoded = decoder(conf_entry)
|
||||||
|
conf_entry_new = conf_file.read()
|
||||||
|
conf_decoded_new = decoder(conf_entry_new)
|
||||||
|
self.assertEqual(conf_decoded, conf_decoded_new)
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@ DEFAULT_ISO_TIME = time.mktime(DEFAULT_TIMESTAMP.timetuple())
|
||||||
|
|
||||||
log = logging.getLogger("lbrynet.tests.util")
|
log = logging.getLogger("lbrynet.tests.util")
|
||||||
|
|
||||||
|
|
||||||
def mk_db_and_blob_dir():
|
def mk_db_and_blob_dir():
|
||||||
db_dir = tempfile.mkdtemp()
|
db_dir = tempfile.mkdtemp()
|
||||||
blob_dir = tempfile.mkdtemp()
|
blob_dir = tempfile.mkdtemp()
|
||||||
|
|
Loading…
Reference in a new issue