ludeeus / googledevices

Get information from, and control various Google devices.
https://pypi.org/project/googledevices/
MIT License
20 stars 4 forks source link

Error when running "googledevices scan-network": "ValueError: 10.2.0.250/24 has host bits set" #46

Open mitchnemirov opened 2 years ago

mitchnemirov commented 2 years ago

Describe the bug When attempting to run googledevices scan-network (or even any of the other network-fetching related options) I get the error below. It appears to be due to how the ipaddress Python module handles IP addresses with host bits when "strict" is set to True.

See the following for the ipaddress python documentation: If strict is True and host bits are set in the supplied address, then ValueError is raised. Otherwise, the host bits are masked out to determine the appropriate network address.

Is there a way to set "strict" to False in the codebase where the ipaddress module is referenced? Or is there another way I can work-around this issue?

Error

Error parsing information - timeout() got an unexpected keyword argument 'loop'
Traceback (most recent call last):
  File "/home/mitch/.local/bin/googledevices", line 8, in <module>
    sys.exit(CLI())
  File "/usr/lib/python3/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python3/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/mitch/.local/lib/python3.9/site-packages/googledevices/cli/cli.py", line 45, in scan_network
    command.scan_network(LOOP, network, feature)
  File "/home/mitch/.local/lib/python3.9/site-packages/googledevices/cli/commands/scan_network.py", line 55, in scan_network
    loop.run_until_complete(get_all_units())
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/home/mitch/.local/lib/python3.9/site-packages/googledevices/cli/commands/scan_network.py", line 47, in get_all_units
    result = await googledevices.scan_for_units(subnet)
  File "/home/mitch/.local/lib/python3.9/site-packages/googledevices/utils/scan.py", line 33, in scan_for_units
    for host in ipaddress.IPv4Network(iprange):
  File "/usr/lib/python3.9/ipaddress.py", line 1509, in __init__
    raise ValueError('%s has host bits set' % self)
ValueError: 10.2.0.250/24 has host bits set
ludeeus commented 2 years ago

Even if that worked, nothing else would, see #44. This entire package needs a full rewrite, and currently, I really don't see that happening anytime soon :/

mitchnemirov commented 2 years ago

I found another project that had functions setup to read chromecast info (status, ip/mac addresses, etc) and they have instructions for getting authentication setup for the new auth flow Google pushed out (Link: https://github.com/rithvikvibhu/GHLocalApi/issues/39).

I understand the sentiment though. No worries here, I haven't taken the time to get auth working with the other tool either as I've done another form of Chromecast testing to troubleshoot issues at work.