Exemple #1
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        self.hostname = network.format_hostname(config['mpd']['hostname'])
        self.port = config['mpd']['port']
        self.uri_map = uri_mapper.MpdUriMapper(core)

        self.zeroconf_name = config['mpd']['zeroconf']
        self.zeroconf_service = None

        try:
            network.Server(
                self.hostname, self.port,
                protocol=session.MpdSession,
                protocol_kwargs={
                    'config': config,
                    'core': core,
                    'uri_map': self.uri_map,
                },
                max_connections=config['mpd']['max_connections'],
                timeout=config['mpd']['connection_timeout'])
        except IOError as error:
            raise exceptions.FrontendError(
                'MPD server startup failed: %s' %
                encoding.locale_decode(error))

        logger.info('MPD server running at [%s]:%s', self.hostname, self.port)
Exemple #2
0
    def __init__(self, config, core):
        super().__init__()

        self.hostname = network.format_hostname(config["http"]["hostname"])
        self.port = config["http"]["port"]
        tornado_hostname = config["http"]["hostname"]
        if tornado_hostname == "::":
            tornado_hostname = None

        try:
            logger.debug("Starting HTTP server")
            sockets = tornado.netutil.bind_sockets(self.port, tornado_hostname)
            self.server = HttpServer(
                config=config,
                core=core,
                sockets=sockets,
                apps=self.apps,
                statics=self.statics,
            )
        except OSError as exc:
            raise exceptions.FrontendError(
                f"HTTP server startup failed: {exc}")

        self.zeroconf_name = config["http"]["zeroconf"]
        self.zeroconf_http = None
        self.zeroconf_mopidy_http = None
Exemple #3
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        self.hostname = network.format_hostname(config['mpd']['hostname'])
        self.port = config['mpd']['port']
        self.uri_map = uri_mapper.MpdUriMapper(core)

        self.zeroconf_name = config['mpd']['zeroconf']
        self.zeroconf_service = None

        try:
            network.Server(self.hostname,
                           self.port,
                           protocol=session.MpdSession,
                           protocol_kwargs={
                               'config': config,
                               'core': core,
                               'uri_map': self.uri_map,
                           },
                           max_connections=config['mpd']['max_connections'],
                           timeout=config['mpd']['connection_timeout'])
        except IOError as error:
            raise exceptions.FrontendError('MPD server startup failed: %s' %
                                           encoding.locale_decode(error))

        logger.info('MPD server running at [%s]:%s', self.hostname, self.port)
    def __init__(self, config, core):
        super(HttpFrontend, self).__init__()

        self.hostname = network.format_hostname(
            config['mopidy_bamp']['hostname'])
        self.port = config['mopidy_bamp']['port']
        tornado_hostname = config['mopidy_bamp']['hostname']
        if tornado_hostname == '::':
            tornado_hostname = None

        try:
            logger.debug('Starting HTTP server')
            sockets = tornado.netutil.bind_sockets(self.port, tornado_hostname)
            self.server = HttpServer(config=config,
                                     core=core,
                                     sockets=sockets,
                                     apps=self.apps,
                                     statics=self.statics)
        except IOError as error:
            raise exceptions.FrontendError('HTTP server startup failed: %s' %
                                           encoding.locale_decode(error))

        self.zeroconf_name = config['mopidy_bamp']['zeroconf']
        self.zeroconf_http = None
        self.zeroconf_mopidy_http = None
Exemple #5
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        self.hostname = network.format_hostname(config['mpd']['hostname'])
        self.port = config['mpd']['port']
        self.uri_map = uri_mapper.MpdUriMapper(core)

        self.zeroconf_name = config['mpd']['zeroconf']
        self.zeroconf_service = None

        self._setup_server(config, core)
Exemple #6
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        self.hostname = network.format_hostname(config['mpd']['hostname'])
        self.port = config['mpd']['port']
        self.uri_map = uri_mapper.MpdUriMapper(core)

        self.zeroconf_name = config['mpd']['zeroconf']
        self.zeroconf_service = None

        self.server = self._setup_server(config, core)
Exemple #7
0
    def __init__(self, config, core):
        super(HttpFrontend, self).__init__()

        self.hostname = network.format_hostname(config["http"]["hostname"])
        self.port = config["http"]["port"]
        tornado_hostname = config["http"]["hostname"]
        if tornado_hostname == "::":
            tornado_hostname = None

        try:
            logger.debug("Starting HTTP server")
            sockets = tornado.netutil.bind_sockets(self.port, tornado_hostname)
            self.server = HttpServer(config=config, core=core, sockets=sockets, apps=self.apps, statics=self.statics)
        except IOError as error:
            raise exceptions.FrontendError("HTTP server startup failed: %s" % encoding.locale_decode(error))

        self.zeroconf_name = config["http"]["zeroconf"]
        self.zeroconf_http = None
        self.zeroconf_mopidy_http = None
Exemple #8
0
    def __init__(self, config, core):
        super(HttpFrontend, self).__init__()

        self.hostname = network.format_hostname(config['http']['hostname'])
        self.port = config['http']['port']
        tornado_hostname = config['http']['hostname']
        if tornado_hostname == '::':
            tornado_hostname = None

        try:
            logger.debug('Starting HTTP server')
            sockets = tornado.netutil.bind_sockets(self.port, tornado_hostname)
            self.server = HttpServer(
                config=config, core=core, sockets=sockets,
                apps=self.apps, statics=self.statics)
        except IOError as error:
            raise exceptions.FrontendError(
                'HTTP server startup failed: %s' %
                encoding.locale_decode(error))

        self.zeroconf_name = config['http']['zeroconf']
        self.zeroconf_http = None
        self.zeroconf_mopidy_http = None
Exemple #9
0
 def test_format_hostname_does_nothing_when_only_ipv4_available(self):
     network.has_ipv6 = False
     self.assertEqual(network.format_hostname('0.0.0.0'), '0.0.0.0')
Exemple #10
0
 def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
     network.has_ipv6 = True
     self.assertEqual(network.format_hostname('0.0.0.0'), '::ffff:0.0.0.0')
     self.assertEqual(network.format_hostname('1.0.0.1'), '::ffff:1.0.0.1')
Exemple #11
0
 def test_format_hostname_does_nothing_when_only_ipv4_available(self):
     network.has_ipv6 = False
     assert network.format_hostname("0.0.0.0") == "0.0.0.0"
Exemple #12
0
 def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
     network.has_ipv6 = True
     assert network.format_hostname("0.0.0.0") == "::ffff:0.0.0.0"
     assert network.format_hostname("1.0.0.1") == "::ffff:1.0.0.1"
Exemple #13
0
 def test_format_hostname_does_nothing_when_only_ipv4_available(self):
     network.has_ipv6 = False
     self.assertEqual(network.format_hostname('0.0.0.0'), '0.0.0.0')
Exemple #14
0
 def test_format_hostname_prefixes_ipv4_addresses_when_ipv6_available(self):
     network.has_ipv6 = True
     self.assertEqual(network.format_hostname('0.0.0.0'), '::ffff:0.0.0.0')
     self.assertEqual(network.format_hostname('1.0.0.1'), '::ffff:1.0.0.1')