Fixed typos and warnings in snapcast backend
This commit is contained in:
parent
3bbbd5edaa
commit
df355fb954
1 changed files with 9 additions and 5 deletions
|
@ -34,7 +34,7 @@ class MusicSnapcastBackend(Backend):
|
|||
_DEFAULT_POLL_SECONDS = 10 # Poll servers each 10 seconds
|
||||
_SOCKET_EOL = '\r\n'.encode()
|
||||
|
||||
def __init__(self, hosts=['localhost'], ports=[_DEFAULT_SNAPCAST_PORT],
|
||||
def __init__(self, hosts=None, ports=None,
|
||||
poll_seconds=_DEFAULT_POLL_SECONDS, *args, **kwargs):
|
||||
"""
|
||||
:param hosts: List of Snapcast server names or IPs to monitor (default:
|
||||
|
@ -52,6 +52,11 @@ class MusicSnapcastBackend(Backend):
|
|||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
if hosts is None:
|
||||
hosts = ['localhost']
|
||||
if ports is None:
|
||||
ports = [self._DEFAULT_SNAPCAST_PORT]
|
||||
|
||||
self.hosts = hosts[:]
|
||||
self.ports = ports[:]
|
||||
self.poll_seconds = poll_seconds
|
||||
|
@ -123,7 +128,7 @@ class MusicSnapcastBackend(Backend):
|
|||
elif msg.get('method') == 'Group.OnStreamChanged':
|
||||
group_id = msg.get('params', {}).get('id')
|
||||
stream_id = msg.get('params', {}).get('stream_id')
|
||||
evt = GroupStreamChangeEvent(host=host, group=group, stream=stream)
|
||||
evt = GroupStreamChangeEvent(host=host, group=group_id, stream=stream_id)
|
||||
elif msg.get('method') == 'Stream.OnUpdate':
|
||||
stream_id = msg.get('params', {}).get('stream_id')
|
||||
stream = msg.get('params', {}).get('stream')
|
||||
|
@ -137,10 +142,9 @@ class MusicSnapcastBackend(Backend):
|
|||
def _client(self, host, port):
|
||||
def _thread():
|
||||
set_thread_name('Snapcast-' + host)
|
||||
status = None
|
||||
|
||||
try:
|
||||
status = self._status(host, port)
|
||||
self._status(host, port)
|
||||
except Exception as e:
|
||||
self.logger.warning(('Exception while getting the status ' +
|
||||
'of the Snapcast server {}:{}: {}').
|
||||
|
@ -200,7 +204,7 @@ class MusicSnapcastBackend(Backend):
|
|||
except Exception as e:
|
||||
self.logger.warning('Unable to connect to {}:{}: {}'.format(
|
||||
host, port, str(e)))
|
||||
self._socks[hosts] = None
|
||||
self._socks[host] = None
|
||||
|
||||
def run(self):
|
||||
super().run()
|
||||
|
|
Loading…
Reference in a new issue