diff --git a/lbrynet/lbrynet_daemon/Daemon.py b/lbrynet/lbrynet_daemon/Daemon.py index 0855ba334..e8e40c6cf 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(): @@ -329,7 +329,7 @@ class Daemon(AuthJSONRPCServer): if conf.settings.host_ui: self.lbry_ui_manager.update_checker.start(1800, now=False) - yield self.lbry_ui_manager.setup() + yield self.lbry_ui_manager.setup(launch=launch_ui) 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..2321ec2d3 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__) @@ -60,7 +59,7 @@ class UIManager(object): self.loaded_branch = None self.loaded_requirements = None - def setup(self, branch=None, check_requirements=None, user_specified=None): + def setup(self, branch=None, check_requirements=None, user_specified=None, launch=False): local_ui_path = user_specified or conf.settings.local_ui_path self.branch = branch or conf.settings.ui_branch @@ -95,6 +94,8 @@ class UIManager(object): d = self._up_to_date() d.addCallback(lambda r: self._download_ui() if not r else self._load_ui()) + if launch: + d.addCallback(lambda _: webbrowser.open(conf.settings.UI_ADDRESS)) return d def _check_for_bundled_ui(self):