fix update settings problem
also move log upload url constant to conf.py
This commit is contained in:
parent
9f0f9e0928
commit
a4a5d63da7
2 changed files with 21 additions and 8 deletions
|
@ -24,6 +24,8 @@ KNOWN_DHT_NODES = [('104.236.42.182', 4000)]
|
||||||
POINTTRADER_SERVER = 'http://ec2-54-187-192-68.us-west-2.compute.amazonaws.com:2424'
|
POINTTRADER_SERVER = 'http://ec2-54-187-192-68.us-west-2.compute.amazonaws.com:2424'
|
||||||
#POINTTRADER_SERVER = 'http://127.0.0.1:2424'
|
#POINTTRADER_SERVER = 'http://127.0.0.1:2424'
|
||||||
|
|
||||||
|
LOG_POST_URL = "https://lbry.io/log-upload"
|
||||||
|
|
||||||
CRYPTSD_FILE_EXTENSION = ".cryptsd"
|
CRYPTSD_FILE_EXTENSION = ".cryptsd"
|
||||||
|
|
||||||
API_INTERFACE = "localhost"
|
API_INTERFACE = "localhost"
|
||||||
|
|
|
@ -38,7 +38,7 @@ from lbrynet.lbrynet_daemon.LBRYPublisher import Publisher
|
||||||
from lbrynet.core.utils import generate_id
|
from lbrynet.core.utils import generate_id
|
||||||
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
from lbrynet.lbrynet_console.LBRYSettings import LBRYSettings
|
||||||
from lbrynet.conf import MIN_BLOB_DATA_PAYMENT_RATE, DEFAULT_MAX_SEARCH_RESULTS, KNOWN_DHT_NODES, DEFAULT_MAX_KEY_FEE, \
|
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
|
DEFAULT_WALLET, DEFAULT_SEARCH_TIMEOUT, DEFAULT_CACHE_TIME, DEFAULT_UI_BRANCH, LOG_POST_URL
|
||||||
from lbrynet.conf import DEFAULT_TIMEOUT, WALLET_TYPES
|
from lbrynet.conf import DEFAULT_TIMEOUT, WALLET_TYPES
|
||||||
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
from lbrynet.core.StreamDescriptor import StreamDescriptorIdentifier, download_sd_blob
|
||||||
from lbrynet.core.Session import LBRYSession
|
from lbrynet.core.Session import LBRYSession
|
||||||
|
@ -410,8 +410,10 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
|
|
||||||
if self.first_run:
|
if self.first_run:
|
||||||
d = self._upload_log(log_type="first_run")
|
d = self._upload_log(log_type="first_run")
|
||||||
else:
|
elif self.upload_log:
|
||||||
d = self._upload_log(exclude_previous=True, log_type="start")
|
d = self._upload_log(exclude_previous=True, log_type="start")
|
||||||
|
else:
|
||||||
|
d = defer.succeed(None)
|
||||||
|
|
||||||
if float(self.session.wallet.wallet_balance) == 0.0:
|
if float(self.session.wallet.wallet_balance) == 0.0:
|
||||||
d.addCallback(lambda _: self._check_first_run())
|
d.addCallback(lambda _: self._check_first_run())
|
||||||
|
@ -619,7 +621,6 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
|
|
||||||
def _upload_log(self, log_type=None, exclude_previous=False, force=False):
|
def _upload_log(self, log_type=None, exclude_previous=False, force=False):
|
||||||
if self.upload_log or force:
|
if self.upload_log or force:
|
||||||
LOG_URL = "https://lbry.io/log-upload"
|
|
||||||
if exclude_previous:
|
if exclude_previous:
|
||||||
f = open(self.log_file, "r")
|
f = open(self.log_file, "r")
|
||||||
f.seek(PREVIOUS_LOG)
|
f.seek(PREVIOUS_LOG)
|
||||||
|
@ -633,11 +634,11 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
'date': datetime.utcnow().strftime('%Y%m%d-%H%M%S'),
|
'date': datetime.utcnow().strftime('%Y%m%d-%H%M%S'),
|
||||||
'hash': base58.b58encode(self.lbryid)[:20],
|
'hash': base58.b58encode(self.lbryid)[:20],
|
||||||
'sys': platform.system(),
|
'sys': platform.system(),
|
||||||
'type': log_type,
|
'type': log_type if log_type else 'default',
|
||||||
'log': log_contents
|
'log': log_contents
|
||||||
}
|
}
|
||||||
|
|
||||||
requests.post(LOG_URL, params)
|
requests.post(LOG_POST_URL, params)
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
else:
|
else:
|
||||||
return defer.succeed(None)
|
return defer.succeed(None)
|
||||||
|
@ -713,16 +714,22 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
elif k == 'download_timeout':
|
elif k == 'download_timeout':
|
||||||
if type(settings['download_timeout']) is int:
|
if type(settings['download_timeout']) is int:
|
||||||
self.session_settings['download_timeout'] = settings['download_timeout']
|
self.session_settings['download_timeout'] = settings['download_timeout']
|
||||||
|
elif type(settings['download_timeout']) is float:
|
||||||
|
self.session_settings['download_timeout'] = int(settings['download_timeout'])
|
||||||
else:
|
else:
|
||||||
return defer.fail()
|
return defer.fail()
|
||||||
elif k == 'search_timeout':
|
elif k == 'search_timeout':
|
||||||
if type(settings['search_timeout']) is float:
|
if type(settings['search_timeout']) is float:
|
||||||
self.session_settings['search_timeout'] = settings['search_timeout']
|
self.session_settings['search_timeout'] = settings['search_timeout']
|
||||||
|
elif type(settings['search_timeout']) is int:
|
||||||
|
self.session_settings['search_timeout'] = float(settings['search_timeout'])
|
||||||
else:
|
else:
|
||||||
return defer.fail()
|
return defer.fail()
|
||||||
elif k == 'cache_time':
|
elif k == 'cache_time':
|
||||||
if type(settings['cache_time']) is int:
|
if type(settings['cache_time']) is int:
|
||||||
self.session_settings['cache_time'] = settings['cache_time']
|
self.session_settings['cache_time'] = settings['cache_time']
|
||||||
|
elif type(settings['cache_time']) is float:
|
||||||
|
self.session_settings['cache_time'] = int(settings['cache_time'])
|
||||||
else:
|
else:
|
||||||
return defer.fail()
|
return defer.fail()
|
||||||
self.run_on_startup = self.session_settings['run_on_startup']
|
self.run_on_startup = self.session_settings['run_on_startup']
|
||||||
|
@ -1482,6 +1489,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
log.info("[" + str(datetime.now()) + "] Set daemon settings to " + json.dumps(self.session_settings))
|
log.info("[" + str(datetime.now()) + "] Set daemon settings to " + json.dumps(self.session_settings))
|
||||||
|
|
||||||
d = self._update_settings(p)
|
d = self._update_settings(p)
|
||||||
|
d.addErrback(lambda err: log.info(err.getTraceback()))
|
||||||
d.addCallback(lambda _: _log_settings_change())
|
d.addCallback(lambda _: _log_settings_change())
|
||||||
d.addCallback(lambda _: self._render_response(self.session_settings, OK_CODE))
|
d.addCallback(lambda _: self._render_response(self.session_settings, OK_CODE))
|
||||||
|
|
||||||
|
@ -2145,17 +2153,18 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
#
|
#
|
||||||
# return d
|
# return d
|
||||||
|
|
||||||
def jsonrpc_log(self, message):
|
def jsonrpc_log(self, p):
|
||||||
"""
|
"""
|
||||||
Log message
|
Log message
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
message: message to be logged
|
'message': message to be logged
|
||||||
Returns:
|
Returns:
|
||||||
True
|
True
|
||||||
"""
|
"""
|
||||||
|
|
||||||
log.info(message)
|
message = p['message']
|
||||||
|
log.info("API client log request: %s" % message)
|
||||||
return self._render_response(True, OK_CODE)
|
return self._render_response(True, OK_CODE)
|
||||||
|
|
||||||
def jsonrpc_upload_log(self, p=None):
|
def jsonrpc_upload_log(self, p=None):
|
||||||
|
@ -2172,6 +2181,8 @@ class LBRYDaemon(jsonrpc.JSONRPC):
|
||||||
if p:
|
if p:
|
||||||
if 'name_prefix' in p.keys():
|
if 'name_prefix' in p.keys():
|
||||||
log_type = p['name_prefix'] + '_api'
|
log_type = p['name_prefix'] + '_api'
|
||||||
|
elif 'log_type' in p.keys():
|
||||||
|
log_type = p['log_type'] + '_api'
|
||||||
else:
|
else:
|
||||||
log_type = None
|
log_type = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue