doc/example: AttributeError: 'ServiceInfo' object has no attribute 'address' #40
Open
Description
% .venv/bin/python
Python 3.8.5 (default, Sep 5 2020, 10:50:12)
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from libsoundtouch import discover_devices
>>> devices = discover_devices(timeout=2)
Exception in thread zeroconf-ServiceBrowser__soundtouch._tcp.local._3897:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File ".../.venv/lib/python3.8/site-packages/zeroconf/__init__.py", line 1721, in run
self._service_state_changed.fire(
File ".../.venv/lib/python3.8/site-packages/zeroconf/__init__.py", line 1479, in fire
h(**kwargs)
File ".../.venv/lib/python3.8/site-packages/zeroconf/__init__.py", line 1577, in on_change
listener.add_service(*args)
File ".../.venv/lib/python3.8/site-packages/libsoundtouch/utils.py", line 102, in add_service
address = socket.inet_ntoa(info.address)
AttributeError: 'ServiceInfo' object has no attribute 'address'
pip freeze
:
certifi==2020.6.20
chardet==3.0.4
enum-compat==0.0.3
idna==2.10
ifaddr==0.1.7
libsoundtouch==0.8.0
requests==2.24.0
six==1.15.0
urllib3==1.25.10
websocket-client==0.57.0
zeroconf==0.28.5
I have not investigated, but this fixed it:
diff --git i/libsoundtouch/utils.py w/libsoundtouch/utils.py
index b097464..5e21e66 100644
--- i/libsoundtouch/utils.py
+++ w/libsoundtouch/utils.py
@@ -99,5 +99,5 @@ def add_service(self, zeroconf, device_type, name):
"""
device_name = (name.split(".")[0])
info = zeroconf.get_service_info(device_type, name)
- address = socket.inet_ntoa(info.address)
+ address = socket.inet_ntoa(info.addresses[0])
self.add_device_function(device_name, address, info.port)
(@ 25163a7)
Metadata
Assignees
Labels
No labels