log LBRYDaemonControl and return None from get_start_notice if there is no notice to give

This commit is contained in:
Jack 2016-04-09 15:43:10 -04:00
parent c11872a229
commit f0d39e6081
2 changed files with 18 additions and 8 deletions

View file

@ -58,9 +58,7 @@ if not os.path.isdir(log_dir):
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log') LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=262144, backupCount=5) handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=262144, backupCount=5)
log.addHandler(handler) log.addHandler(handler)
STARTUP_STAGES = [ STARTUP_STAGES = [
@ -226,7 +224,7 @@ class LBRYDaemon(jsonrpc.JSONRPC):
self.max_key_fee = DEFAULT_MAX_KEY_FEE self.max_key_fee = DEFAULT_MAX_KEY_FEE
self.max_search_results = DEFAULT_MAX_SEARCH_RESULTS self.max_search_results = DEFAULT_MAX_SEARCH_RESULTS
self.startup_status = STARTUP_STAGES[0] self.startup_status = STARTUP_STAGES[0]
self.startup_message = "" self.startup_message = None
self.announced_startup = False self.announced_startup = False
self.search_timeout = 3.0 self.search_timeout = 3.0
self.query_handlers = {} self.query_handlers = {}
@ -874,20 +872,27 @@ class LBRYDaemon(jsonrpc.JSONRPC):
return self._render_response(r, OK_CODE) return self._render_response(r, OK_CODE)
def jsonrpc_is_first_run(self): def jsonrpc_is_first_run(self):
"""
Get True/False if can be determined, if wallet still is being set up returns None
"""
log.info("[" + str(datetime.now()) + "] Check if is first run")
try: try:
d = self.session.wallet.is_first_run() d = self.session.wallet.is_first_run()
except: except:
d = defer.fail(None) d = defer.fail(None)
d.addCallbacks(lambda r: self._render_response(r, OK_CODE), lambda _: server.failure) d.addCallbacks(lambda r: self._render_response(r, OK_CODE), lambda _: self._render_response(None, OK_CODE))
return d return d
def jsonrpc_get_start_notice(self): def jsonrpc_get_start_notice(self):
if self.startup_message: """
return self._render_response(self.startup_message, OK_CODE) Get any special message to be displayed at startup, such as a first run notice
else: """
return defer.fail(None)
log.info("[" + str(datetime.now()) + "] Get startup notice")
return self._render_response(self.startup_message, OK_CODE)
def jsonrpc_get_settings(self): def jsonrpc_get_settings(self):
""" """

View file

@ -24,9 +24,14 @@ if sys.platform != "darwin":
else: else:
log_dir = user_data_dir("LBRY") log_dir = user_data_dir("LBRY")
if not os.path.isdir(log_dir):
os.mkdir(log_dir)
LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log') LOG_FILENAME = os.path.join(log_dir, 'lbrynet-daemon.log')
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
handler = logging.handlers.RotatingFileHandler(LOG_FILENAME, maxBytes=262144, backupCount=5)
log.addHandler(handler)
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)