forked from LBRYCommunity/lbry-sdk
upload log if lbry id is not yet set, clean up crash log
This commit is contained in:
parent
3c7eec9456
commit
127987f3ba
1 changed files with 20 additions and 16 deletions
|
@ -127,6 +127,8 @@ BAD_REQUEST = 400
|
||||||
NOT_FOUND = 404
|
NOT_FOUND = 404
|
||||||
OK_CODE = 200
|
OK_CODE = 200
|
||||||
|
|
||||||
|
PENDING_LBRY_ID = "not set"
|
||||||
|
|
||||||
|
|
||||||
class Checker:
|
class Checker:
|
||||||
"""The looping calls the daemon runs"""
|
"""The looping calls the daemon runs"""
|
||||||
|
@ -263,7 +265,7 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
self.uploaded_temp_files = []
|
self.uploaded_temp_files = []
|
||||||
self._session_id = base58.b58encode(generate_id())
|
self._session_id = base58.b58encode(generate_id())
|
||||||
self.analytics_manager = None
|
self.analytics_manager = None
|
||||||
self.lbryid = None
|
self.lbryid = PENDING_LBRY_ID
|
||||||
|
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
|
||||||
|
@ -837,17 +839,19 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
for lm, lp in [('lbrynet', lbrynet_log)]:
|
for lm, lp in [('lbrynet', lbrynet_log)]:
|
||||||
if os.path.isfile(lp):
|
if os.path.isfile(lp):
|
||||||
if exclude_previous:
|
if exclude_previous:
|
||||||
f = open(lp, "r")
|
with open( lp, "r") as f:
|
||||||
f.seek(PREVIOUS_NET_LOG)
|
f.seek(PREVIOUS_NET_LOG)
|
||||||
log_contents = f.read()
|
log_contents = f.read()
|
||||||
f.close()
|
|
||||||
else:
|
else:
|
||||||
f = open(lp, "r")
|
with open(lp, "r") as f:
|
||||||
log_contents = f.read()
|
log_contents = f.read()
|
||||||
f.close()
|
if self.lbryid is not PENDING_LBRY_ID:
|
||||||
|
id_hash = base58.b58encode(self.lbryid)[:20]
|
||||||
|
else:
|
||||||
|
id_hash = self.lbryid
|
||||||
params = {
|
params = {
|
||||||
'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': id_hash,
|
||||||
'sys': platform.system(),
|
'sys': platform.system(),
|
||||||
'type': "%s-%s" % (lm, log_type) if log_type else lm,
|
'type': "%s-%s" % (lm, log_type) if log_type else lm,
|
||||||
'log': log_contents
|
'log': log_contents
|
||||||
|
@ -995,7 +999,7 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
if os.path.exists(db_revision_file):
|
if os.path.exists(db_revision_file):
|
||||||
old_revision = int(open(db_revision_file).read().strip())
|
old_revision = int(open(db_revision_file).read().strip())
|
||||||
if old_revision > self.current_db_revision:
|
if old_revision > self.current_db_revision:
|
||||||
raise Exception('This version of lbrynet is not compatible with the database')
|
return defer.fail(Exception('This version of lbrynet is not compatible with the database'))
|
||||||
if old_revision < self.current_db_revision:
|
if old_revision < self.current_db_revision:
|
||||||
from lbrynet.db_migrator import dbmigrator
|
from lbrynet.db_migrator import dbmigrator
|
||||||
log.info("Upgrading your databases...")
|
log.info("Upgrading your databases...")
|
||||||
|
@ -1023,7 +1027,7 @@ class Daemon(jsonrpc.JSONRPC):
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _set_lbryid(self, lbryid):
|
def _set_lbryid(self, lbryid):
|
||||||
if lbryid is None:
|
if lbryid is PENDING_LBRY_ID:
|
||||||
return self._make_lbryid()
|
return self._make_lbryid()
|
||||||
else:
|
else:
|
||||||
log.info("LBRY ID: " + base58.b58encode(lbryid))
|
log.info("LBRY ID: " + base58.b58encode(lbryid))
|
||||||
|
|
Loading…
Reference in a new issue