upload log if lbry id is not yet set, clean up crash log

This commit is contained in:
Jack 2016-10-26 16:47:22 -04:00 committed by Job Evers-Meltzer
parent 3c7eec9456
commit 127987f3ba

View file

@ -127,6 +127,8 @@ BAD_REQUEST = 400
NOT_FOUND = 404
OK_CODE = 200
PENDING_LBRY_ID = "not set"
class Checker:
"""The looping calls the daemon runs"""
@ -263,7 +265,7 @@ class Daemon(jsonrpc.JSONRPC):
self.uploaded_temp_files = []
self._session_id = base58.b58encode(generate_id())
self.analytics_manager = None
self.lbryid = None
self.lbryid = PENDING_LBRY_ID
if os.name == "nt":
from lbrynet.winhelpers.knownpaths import get_path, FOLDERID, UserHandle
@ -837,21 +839,23 @@ class Daemon(jsonrpc.JSONRPC):
for lm, lp in [('lbrynet', lbrynet_log)]:
if os.path.isfile(lp):
if exclude_previous:
f = open(lp, "r")
f.seek(PREVIOUS_NET_LOG)
log_contents = f.read()
f.close()
with open( lp, "r") as f:
f.seek(PREVIOUS_NET_LOG)
log_contents = f.read()
else:
f = open(lp, "r")
log_contents = f.read()
f.close()
with open(lp, "r") as f:
log_contents = f.read()
if self.lbryid is not PENDING_LBRY_ID:
id_hash = base58.b58encode(self.lbryid)[:20]
else:
id_hash = self.lbryid
params = {
'date': datetime.utcnow().strftime('%Y%m%d-%H%M%S'),
'hash': base58.b58encode(self.lbryid)[:20],
'sys': platform.system(),
'type': "%s-%s" % (lm, log_type) if log_type else lm,
'log': log_contents
}
'date': datetime.utcnow().strftime('%Y%m%d-%H%M%S'),
'hash': id_hash,
'sys': platform.system(),
'type': "%s-%s" % (lm, log_type) if log_type else lm,
'log': log_contents
}
requests.post(LOG_POST_URL, params)
return defer.succeed(None)
@ -995,7 +999,7 @@ class Daemon(jsonrpc.JSONRPC):
if os.path.exists(db_revision_file):
old_revision = int(open(db_revision_file).read().strip())
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:
from lbrynet.db_migrator import dbmigrator
log.info("Upgrading your databases...")
@ -1023,7 +1027,7 @@ class Daemon(jsonrpc.JSONRPC):
return d
def _set_lbryid(self, lbryid):
if lbryid is None:
if lbryid is PENDING_LBRY_ID:
return self._make_lbryid()
else:
log.info("LBRY ID: " + base58.b58encode(lbryid))