5kyc0d3r / upnpy

Lightweight UPnP client library for Python.
https://upnpy.readthedocs.io
MIT License
60 stars 18 forks source link

nonnumeric port in upnp.discover() #10

Open 5kyc0d3r opened 4 years ago

5kyc0d3r commented 4 years ago

Original post:

I get a different error but another issue with upnp.discover():

>>> upnp.discover()
Traceback (most recent call last):
  File "/usr/lib/python3.6/http/client.py", line 897, in _get_hostport
    port = int(host[i+1:])
ValueError: invalid literal for int() with base 10: '49152wps_scpd.xml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/upnpy/upnp/UPnP.py", line 33, in discover
    for device in self.ssdp.m_search(discover_delay=delay, st='upnp:rootdevice', **headers):
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPRequest.py", line 50, in m_search
    devices = self._send_request(self._get_raw_request())
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPRequest.py", line 100, in _send_request
    device = SSDPDevice(addr, response.decode())
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 87, in __init__
    self._get_services_request()
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 23, in wrapper
    return func(device, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 54, in wrapper
    return func(instance, *args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 179, in _get_services_request
    base_url=base_url
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 257, in __init__
    self._get_description_request()
  File "/usr/local/lib/python3.6/dist-packages/upnpy/ssdp/SSDPDevice.py", line 289, in _get_description_request
    service_description = utils.make_http_request(self.base_url + self.scpd_url).read()
  File "/usr/local/lib/python3.6/dist-packages/upnpy/utils.py", line 81, in make_http_request
    return urllib.request.urlopen(request)
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1353, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1293, in do_open
    h = http_class(host, timeout=req.timeout, **http_conn_args)
  File "/usr/lib/python3.6/http/client.py", line 859, in __init__
    (self.host, self.port) = self._get_hostport(host, port)
  File "/usr/lib/python3.6/http/client.py", line 902, in _get_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
http.client.InvalidURL: nonnumeric port: '49152wps_scpd.xml'

Originally posted by @nashant in https://github.com/5kyc0d3r/upnpy/issues/7#issuecomment-657202199

5kyc0d3r commented 4 years ago

Duplicate of #9

5kyc0d3r commented 4 years ago

Hi @nashant, thanks for your issue. Does 1be5dab2f6356a625980aef067cf1ec285305982 fix this? Please try upgrading upnpy:

pip install upnpy --upgrade