Merge pull request #379 from lbryio/open-ui-asap

open the ui as soon as possible
This commit is contained in:
Job Evers‐Meltzer 2017-01-03 15:28:50 -06:00 committed by GitHub
commit 38e6b4e6c6
4 changed files with 10 additions and 9 deletions

View file

@ -291,7 +291,7 @@ class Daemon(AuthJSONRPCServer):
self.lbry_file_manager = None
@defer.inlineCallbacks
def setup(self):
def setup(self, launch_ui):
self._modify_loggly_formatter()
def _announce_startup():
@ -330,6 +330,8 @@ class Daemon(AuthJSONRPCServer):
if conf.settings.host_ui:
self.lbry_ui_manager.update_checker.start(1800, now=False)
yield self.lbry_ui_manager.setup()
if launch_ui:
self.lbry_ui_manager.launch()
yield self._initial_setup()
yield threads.deferToThread(self._setup_data_directory)
yield self._check_db_migration()

View file

@ -2,7 +2,6 @@ from lbrynet.core import log_support
import argparse
import logging.handlers
import webbrowser
from twisted.internet import defer, reactor
from jsonrpc.proxy import JSONRPCProxy
@ -129,9 +128,7 @@ def start_server_and_listen(launchui, use_auth, analytics_manager):
log_support.configure_analytics_handler(analytics_manager)
try:
daemon_server = DaemonServer(analytics_manager)
yield daemon_server.start(use_auth)
if launchui:
yield webbrowser.open(conf.settings.UI_ADDRESS)
yield daemon_server.start(use_auth, launchui)
analytics_manager.send_server_startup_success()
except Exception as e:
log.exception('Failed to startup')

View file

@ -43,9 +43,9 @@ class DaemonServer(object):
return defer.succeed(True)
@defer.inlineCallbacks
def start(self, use_auth):
def start(self, use_auth, launch_ui=False):
yield self._setup_server(use_auth)
yield self._api.setup()
yield self._api.setup(launch_ui)
def get_site_base(use_auth, root):

View file

@ -2,6 +2,7 @@ import os
import logging
import shutil
import json
import webbrowser
from urllib2 import urlopen
from StringIO import StringIO
from zipfile import ZipFile
@ -15,8 +16,6 @@ from lbrynet.lbrynet_daemon.Resources import NoCacheStaticFile
from lbrynet import __version__ as lbrynet_version
from lbryum.version import LBRYUM_VERSION as lbryum_version
log = logging.getLogger(__name__)
@ -212,6 +211,9 @@ class UIManager(object):
def _load_ui(self):
return load_ui(self.root, self.active_dir)
def launch(self):
webbrowser.open(conf.settings.UI_ADDRESS)
class BundledUIManager(object):
"""Copies the UI bundled with lbrynet, if available.