Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc/example: AttributeError: 'ServiceInfo' object has no attribute 'address' #40

Open
blueyed opened this issue Sep 28, 2020 · 2 comments

Comments

@blueyed
Copy link

blueyed commented Sep 28, 2020

% .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)

@TuurNeckebroeck
Copy link

I had the same issue and can confirm this solution.

@kartikay-bagla
Copy link

This worked for me as well.
@CharlesBlonde is it possible to fix this issue in a future update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants