avahi: Simplify config to single value

This commit is contained in:
Thomas Adamcik 2013-11-11 21:42:23 +01:00
parent e9c2816354
commit c964d15ac4
6 changed files with 8 additions and 14 deletions

View File

@ -21,8 +21,7 @@ class Extension(ext.Extension):
schema['hostname'] = config.Hostname()
schema['port'] = config.Port()
schema['static_dir'] = config.Path(optional=True)
schema['zeroconf_enabled'] = config.Boolean()
schema['zeroconf_name'] = config.String()
schema['zeroconf'] = config.String(optional=True)
return schema
def validate_environment(self):

View File

@ -93,10 +93,9 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
cherrypy.engine.start()
logger.info('HTTP server running at %s', cherrypy.server.base())
if self.config_section['zeroconf_enabled']:
name = self.config_section['zeroconf_name']
if self.config_section['zeroconf']:
self.zeroconf_service = zeroconf.Zeroconf(
stype='_http._tcp', name=name,
stype='_http._tcp', name=self.config_section['zeroconf'],
host=self.hostname, port=self.port)
if self.zeroconf_service.publish():

View File

@ -3,8 +3,7 @@ enabled = true
hostname = 127.0.0.1
port = 6680
static_dir =
zeroconf_enabled = true
zeroconf_name = Mopidy HTTP server on $hostname
zeroconf = Mopidy HTTP server on $hostname
[loglevels]
cherrypy = warning

View File

@ -23,8 +23,7 @@ class Extension(ext.Extension):
schema['password'] = config.Secret(optional=True)
schema['max_connections'] = config.Integer(minimum=1)
schema['connection_timeout'] = config.Integer(minimum=1)
schema['zeroconf_enabled'] = config.Boolean()
schema['zeroconf_name'] = config.String()
schema['zeroconf'] = config.String(optional=True)
return schema
def validate_environment(self):

View File

@ -41,10 +41,9 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener):
logger.info('MPD server running at [%s]:%s', hostname, port)
def on_start(self):
if self.config_section['zeroconf_enabled']:
name = self.config_section['zeroconf_name']
if self.config_section['zeroconf']:
self.zeroconf_service = zeroconf.Zeroconf(
stype="_mpd._tcp", name=name,
stype="_mpd._tcp", name=self.config_section['zeroconf'],
port=self.port, host=self.hostname)
if self.zeroconf_service.publish():

View File

@ -5,5 +5,4 @@ port = 6600
password =
max_connections = 20
connection_timeout = 60
zeroconf_enabled = true
zeroconf_name = Mopidy MPD server on $hostname
zeroconf = Mopidy MPD server on $hostname