Exemple #1
0
class DaemonServer(object):
    def __init__(self, analytics_manager=None):
        self.root = None
        self.analytics_manager = analytics_manager

    def _setup_server(self, use_auth):
        ui_path = os.path.join(conf.settings.ensure_data_dir(), "lbry-ui", "active")
        self.root = LBRYindex(ui_path)
        self._api = Daemon(self.root, self.analytics_manager)
        self.root.putChild("view", HostedEncryptedFile(self._api))
        self.root.putChild("upload", EncryptedFileUpload(self._api))
        self.root.putChild(conf.settings['API_ADDRESS'], self._api)

        lbrynet_server = server.Site(get_site_base(use_auth, self.root))
        lbrynet_server.requestFactory = DaemonRequest

        try:
            reactor.listenTCP(
                conf.settings['api_port'], lbrynet_server, interface=conf.settings['api_host'])
        except error.CannotListenError:
            log.info('Daemon already running, exiting app')
            sys.exit(1)

        return defer.succeed(True)

    @defer.inlineCallbacks
    def start(self, use_auth, launch_ui=False):
        yield self._setup_server(use_auth)
        yield self._api.setup(launch_ui)
Exemple #2
0
class DaemonServer(object):
    def __init__(self, analytics_manager=None):
        self.root = None
        self.analytics_manager = analytics_manager

    def _setup_server(self, use_auth):
        ui_path = os.path.join(settings.ensure_data_dir(), "lbry-ui", "active")
        self.root = LBRYindex(ui_path)
        self._api = Daemon(self.root, self.analytics_manager)
        self.root.putChild("view", HostedEncryptedFile(self._api))
        self.root.putChild("upload", EncryptedFileUpload(self._api))
        self.root.putChild(settings.API_ADDRESS, self._api)

        lbrynet_server = server.Site(get_site_base(use_auth, self.root))
        lbrynet_server.requestFactory = DaemonRequest

        try:
            reactor.listenTCP(settings.api_port, lbrynet_server, interface=settings.API_INTERFACE)
        except error.CannotListenError:
            log.info('Daemon already running, exiting app')
            sys.exit(1)

        return defer.succeed(True)

    def start(self, use_auth):
        d = self._setup_server(use_auth)
        d.addCallback(lambda _: self._api.setup())
        return d
Exemple #3
0
class DaemonServer(object):
    def _setup_server(self, wallet):
        self.root = LBRYindex(os.path.join(os.path.join(data_dir, "lbry-ui"), "active"))
        self._api = Daemon(self.root, wallet_type=wallet)
        self.root.putChild("view", HostedEncryptedFile(self._api))
        self.root.putChild("upload", EncryptedFileUpload(self._api))
        self.root.putChild(API_ADDRESS, self._api)
        return defer.succeed(True)

    def start(self, branch=DEFAULT_UI_BRANCH, user_specified=False, branch_specified=False, wallet=None):
        d = self._setup_server(wallet)
        d.addCallback(lambda _: self._api.setup(branch, user_specified, branch_specified))
        return d
Exemple #4
0
class DaemonServer(object):
    def _setup_server(self, wallet):
        self.root = LBRYindex(
            os.path.join(os.path.join(data_dir, "lbry-ui"), "active"))
        self._api = Daemon(self.root, wallet_type=wallet)
        self.root.putChild("view", HostedEncryptedFile(self._api))
        self.root.putChild("upload", EncryptedFileUpload(self._api))
        self.root.putChild(API_ADDRESS, self._api)
        return defer.succeed(True)

    def start(self,
              branch=DEFAULT_UI_BRANCH,
              user_specified=False,
              branch_specified=False,
              wallet=None):
        d = self._setup_server(wallet)
        d.addCallback(lambda _: self._api.setup(branch, user_specified,
                                                branch_specified))
        return d