Open l0rddarkf0rce opened 2 years ago
The error occurs by just running upnpclient.discover()
Same error here.
$ python3
Python 3.8.10 (default, Jun 22 2022, 20:18:18)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import upnpclient
>>> devices = upnpclient.discover()
Error '404 Client Error: Not Found for url: http://192.168.178.39:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f2ed160>
Error '404 Client Error: Not Found for url: http://192.168.178.37:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4c40>
Error '404 Client Error: Not Found for url: http://192.168.178.37:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4d60>
Error '404 Client Error: Not Found for url: http://192.168.178.39:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f0991a45d90>
Error '404 Client Error: Not Found for url: http://192.168.178.39:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4dc0>
Error '404 Client Error: Not Found for url: http://192.168.178.37:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4df0>
Error '404 Client Error: Not Found for url: http://192.168.178.39:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4ee0>
Error '404 Client Error: Not Found for url: http://192.168.178.37:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4f40>
Error '404 Client Error: Not Found for url: http://192.168.178.39:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4fa0>
Error '404 Client Error: Not Found for url: http://192.168.178.37:8008/ssdp/notfound' for <upnpclient.ssdp.Entry object at 0x7f098f1b4fd0>
>>>
Ugly workaround: temporarily redirect stderror to /dev/null:
safe_stderr = sys.stderr
sys.stderr = open(os.devnull,'w')
devices = upnpclient.discover()
sys.stderr = safe_stderr
I assume the error is from:
https://github.com/flyte/upnpclient/blob/develop/upnpclient/ssdp.py#L126
I'm not sure, but maybe you can overwrite that ... ?
log = _getLogger("ssdp")
log.error("Error '%s' for %s", exc, entry)
EDIT:
Commenting out that line in .local/lib/python3.8/site-packages/upnpclient/ssdp.py
indeed avoids the error message
Any feedback on this?
Anything better than the workaround below?
#!/usr/bin/env python3
import upnpclient
import sys, os
# workaround: redirect stderr
safe_stderr = sys.stderr
sys.stderr = open(os.devnull,'w')
devices = upnpclient.discover()
sys.stderr = safe_stderr
for i in devices:
print(i)
try:
print(i.WANIPConn1.GetExternalIPAddress())
except:
pass
I have the following simple code
and when I run it I get the following error?
Error '404 Client Error: Not Found for url: http[:]//192.168.1.220:8060/dial/ecp_SCPD.xml' for <upnpclient.ssdp.Entry object at 0x000001F68CB1E310>
Any ideas on how to ignore and/or fix it?