avahi: Fixes from review comments
This commit is contained in:
parent
6c6932c374
commit
fb31193ed0
@ -96,13 +96,13 @@ class HttpFrontend(pykka.ThreadingActor, CoreListener):
|
||||
if self.config_section['zeroconf_enabled']:
|
||||
name = self.config_section['zeroconf_name']
|
||||
self.zeroconf_service = zeroconf.Zeroconf(
|
||||
stype="_http._tcp", name=name, port=self.port,
|
||||
host=self.hostname)
|
||||
stype='_http._tcp', name=name,
|
||||
host=self.hostname, port=self.port)
|
||||
|
||||
if self.zeroconf_service.publish():
|
||||
logger.info('Registered HTTP with zeroconf as %s', name)
|
||||
logger.info('Registered HTTP with Zeroconf as %s', name)
|
||||
else:
|
||||
logger.warning('Registering HTTP with zeroconf failed.')
|
||||
logger.warning('Registering HTTP with Zeroconf failed.')
|
||||
|
||||
def on_stop(self):
|
||||
if self.zeroconf_service:
|
||||
|
||||
@ -44,13 +44,13 @@ class MpdFrontend(pykka.ThreadingActor, CoreListener):
|
||||
if self.config_section['zeroconf_enabled']:
|
||||
name = self.config_section['zeroconf_name']
|
||||
self.zeroconf_service = zeroconf.Zeroconf(
|
||||
stype="_mpd._tcp", name=name, port=self.port,
|
||||
host=self.hostname)
|
||||
stype="_mpd._tcp", name=name,
|
||||
port=self.port, host=self.hostname)
|
||||
|
||||
if self.zeroconf_service.publish():
|
||||
logger.info('Registered MPD with zeroconf as %s', name)
|
||||
logger.info('Registered MPD with Zeroconf as %s', name)
|
||||
else:
|
||||
logger.warning('Registering MPD with zeroconf failed.')
|
||||
logger.warning('Registering MPD with Zeroconf failed.')
|
||||
|
||||
def on_stop(self):
|
||||
if self.zeroconf_service:
|
||||
|
||||
@ -15,7 +15,6 @@ _AVAHI_PROTO_UNSPEC = -1
|
||||
_AVAHI_PUBLISHFLAGS_NONE = 0
|
||||
|
||||
|
||||
|
||||
def _filter_loopback_and_meta_addresses(host):
|
||||
# TODO: see if we can find a cleaner way of handling this.
|
||||
if re.search(r'(?<![.\d])(127|0)[.]', host):
|
||||
@ -28,7 +27,7 @@ def _convert_text_to_dbus_bytes(text):
|
||||
|
||||
|
||||
class Zeroconf:
|
||||
"""Publish a network service with zeroconf using avahi."""
|
||||
"""Publish a network service with zeroconf using Avahi."""
|
||||
|
||||
def __init__(self, name, port, stype="_http._tcp",
|
||||
domain="", host="", text=[]):
|
||||
@ -52,7 +51,7 @@ class Zeroconf:
|
||||
return False
|
||||
|
||||
if not bus.name_has_owner('org.freedesktop.Avahi'):
|
||||
logger.debug('Zeroconf publish failed: avahi service not running.')
|
||||
logger.debug('Zeroconf publish failed: Avahi service not running.')
|
||||
return False
|
||||
|
||||
server = dbus.Interface(bus.get_object("org.freedesktop.Avahi", "/"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user