Exemplo n.º 1
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        hostname = network.format_hostname(config['mpd']['hostname'])
        self.hostname = hostname
        self.port = config['mpd']['port']
        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,
                },
                max_connections=config['mpd']['max_connections'],
                timeout=config['mpd']['connection_timeout'])
        except IOError as error:
            logger.error(
                'MPD server startup failed: %s',
                encoding.locale_decode(error))
            sys.exit(1)

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

        self.hostname = network.format_hostname(config['mpd']['hostname'])
        self.port = config['mpd']['port']

        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,
                },
                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)
Exemplo n.º 3
0
    def __init__(self):
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        try:
            network.Server(hostname, port, protocol=MpdSession,
                max_connections=settings.MPD_SERVER_MAX_CONNECTIONS)
        except IOError, e:
            logger.error(u'MPD server startup failed: %s', e)
            sys.exit(1)
Exemplo n.º 4
0
    def __init__(self):
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        try:
            network.Server(hostname,
                           port,
                           protocol=MpdSession,
                           max_connections=settings.MPD_SERVER_MAX_CONNECTIONS)
        except IOError, e:
            logger.error(u'MPD server startup failed: %s', e)
            sys.exit(1)
Exemplo n.º 5
0
    def __init__(self):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        try:
            network.Server(hostname, port, protocol=MpdSession,
                max_connections=settings.MPD_SERVER_MAX_CONNECTIONS)
        except IOError as error:
            logger.error(u'MPD server startup failed: %s', locale_decode(error))
            sys.exit(1)

        logger.info(u'MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 6
0
 def start(self):
     """Start MPD server."""
     try:
         self.set_socket(network.create_socket())
         self.set_reuse_addr()
         hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
         port = settings.MPD_SERVER_PORT
         logger.debug(u'MPD server is binding to [%s]:%s', hostname, port)
         self.bind((hostname, port))
         self.listen(1)
         logger.info(u'MPD server running at [%s]:%s', hostname, port)
     except IOError, e:
         logger.error(u'MPD server startup failed: %s' %
             str(e).decode('utf-8'))
         sys.exit(1)
Exemplo n.º 7
0
    def __init__(self):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        try:
            network.Server(hostname,
                           port,
                           protocol=MpdSession,
                           max_connections=settings.MPD_SERVER_MAX_CONNECTIONS)
        except IOError as error:
            logger.error(u'MPD server startup failed: %s',
                         locale_decode(error))
            sys.exit(1)

        logger.info(u'MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 8
0
    def __init__(self, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        try:
            network.Server(
                hostname, port,
                protocol=session.MpdSession, protocol_kwargs={'core': core},
                max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
                timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT)
        except IOError as error:
            logger.error(
                'MPD server startup failed: %s',
                encoding.locale_decode(error))
            sys.exit(1)

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 9
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
Exemplo n.º 10
0
    def __init__(self, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
        # See https://github.com/mopidy/mopidy/issues/302 for details.
        try:
            network.Server(hostname,
                           port,
                           protocol=session.MpdSession,
                           protocol_kwargs={b'core': core},
                           max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
                           timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT)
        except IOError as error:
            logger.error('MPD server startup failed: %s',
                         encoding.locale_decode(error))
            sys.exit(1)

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 11
0
    def __init__(self, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(settings.MPD_SERVER_HOSTNAME)
        port = settings.MPD_SERVER_PORT

        # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
        # See https://github.com/mopidy/mopidy/issues/302 for details.
        try:
            network.Server(
                hostname, port,
                protocol=session.MpdSession, protocol_kwargs={b'core': core},
                max_connections=settings.MPD_SERVER_MAX_CONNECTIONS,
                timeout=settings.MPD_SERVER_CONNECTION_TIMEOUT)
        except IOError as error:
            logger.error(
                'MPD server startup failed: %s',
                encoding.locale_decode(error))
            sys.exit(1)

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 12
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()

        self.hostname = network.format_hostname(config["mpd"]["hostname"])
        self.port = config["mpd"]["port"]

        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},
                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)
Exemplo n.º 13
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(config['mpd']['hostname'])
        port = config['mpd']['port']

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

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 14
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(config['mpd']['hostname'])
        port = config['mpd']['port']

        # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
        # See https://github.com/mopidy/mopidy/issues/302 for details.
        try:
            network.Server(hostname,
                           port,
                           protocol=session.MpdSession,
                           protocol_kwargs={
                               b'config': config,
                               b'core': core,
                           },
                           max_connections=config['mpd']['max_connections'],
                           timeout=config['mpd']['connection_timeout'])
        except IOError as error:
            logger.error('MPD server startup failed: %s',
                         encoding.locale_decode(error))
            sys.exit(1)

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 15
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
Exemplo n.º 16
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
Exemplo n.º 17
0
    def __init__(self, config, core):
        super(MpdFrontend, self).__init__()
        hostname = network.format_hostname(config['mpd']['hostname'])
        port = config['mpd']['port']

        # NOTE kwargs dict keys must be bytestrings to work on Python < 2.6.5
        # See https://github.com/mopidy/mopidy/issues/302 for details.
        try:
            network.Server(
                hostname, port,
                protocol=session.MpdSession,
                protocol_kwargs={
                    b'config': config,
                    b'core': core,
                },
                max_connections=config['mpd']['max_connections'],
                timeout=config['mpd']['connection_timeout'])
        except IOError as error:
            logger.error(
                'MPD server startup failed: %s',
                encoding.locale_decode(error))
            sys.exit(1)

        logger.info('MPD server running at [%s]:%s', hostname, port)
Exemplo n.º 18
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')
Exemplo n.º 19
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")
Exemplo n.º 20
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")
Exemplo n.º 21
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')