diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index d3cd33037..c9b316c23 100644 --- a/lbrynet/lbrynet_daemon/Daemon.py +++ b/lbrynet/lbrynet_daemon/Daemon.py @@ -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() diff --git a/lbrynet/lbrynet_daemon/DaemonControl.py b/lbrynet/lbrynet_daemon/DaemonControl.py index 33a8568b9..541880491 100644 --- a/lbrynet/lbrynet_daemon/DaemonControl.py +++ b/lbrynet/lbrynet_daemon/DaemonControl.py @@ -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') diff --git a/lbrynet/lbrynet_daemon/DaemonServer.py b/lbrynet/lbrynet_daemon/DaemonServer.py index 744563476..b58f9de17 100644 --- a/lbrynet/lbrynet_daemon/DaemonServer.py +++ b/lbrynet/lbrynet_daemon/DaemonServer.py @@ -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): diff --git a/lbrynet/lbrynet_daemon/UIManager.py b/lbrynet/lbrynet_daemon/UIManager.py index 2befcb856..0624d513c 100644 --- a/lbrynet/lbrynet_daemon/UIManager.py +++ b/lbrynet/lbrynet_daemon/UIManager.py @@ -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.