gabrielmagno/nano-dlna

Errors on python 3.10

Closed this issue ยท 16 comments

nanodlna list
nano-dlna log will be saved here: /tmp/tmplrlgcziw/nanodlna-2022-02-05_14-24-40.log
Traceback (most recent call last):
File "/usr/bin/nanodlna", line 8, in
sys.exit(run())
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 150, in run
args.func(args)
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 55, in list_devices
my_devices = devices.get_devices(args.timeout)
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in get_devices
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 40, in register_device
friendly_name = info.find("./device/friendlyName").text
AttributeError: 'NoneType' object has no attribute 'text'

And service_identity needs as dependency.

Hi @vansatchen.

Sorry for the late response.

I've just tested nano-dlna with Python 3.10.4 and it seems to be working around here.

So I think that the error you are getting is not related to the Python 3.10 itself.

Could you please run it with the debug flag, and share here the log it created?

nanodlna --debug list

Feel free to remove or redact from the log file any personal information that you are not comfortable sharing (e.g. IP adresses).

Also, I did not have to instal service_identity, but maybe it is a dependency necessary in other systems (Windows?). What platform and OS are running nano-dlna on? If possible, could you share the error o message that appears when you try to run/install nano-dlna without installing service_identity?

Thank you!

Hi @gabrielmagno!
My system is Arch linux with latest stable updates, Python 3.10.4
Output from "nanodlna --debug list" is the same as "nanodlna list":
nanodlna --debug list
nano-dlna log will be saved here: /tmp/tmprsetk8x_/nanodlna-2022-05-11_09-55-03.log
Traceback (most recent call last):
File "/usr/bin/nanodlna", line 8, in
sys.exit(run())
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 150, in run
args.func(args)
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 55, in list_devices
my_devices = devices.get_devices(args.timeout)
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in get_devices
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 40, in register_device
friendly_name = info.find("./device/friendlyName").text
AttributeError: 'NoneType' object has no attribute 'text'

In additional, if no dlna devices in my lan, nanodlna list output empty, without errors. This error reproduce only if my TV is on lan.
TV is Samsung smart. May be its just specific error for samsung TV?

About service_identity. If i uninstall service_identity by pip, getting this error:
nanodlna list
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''. Please install it from https://pypi.python.org/pypi/service_identity and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
nano-dlna log will be saved here: /tmp/tmpow_zq0w3/nanodlna-2022-05-11_10-10-45.log
Traceback (most recent call last):
File "/usr/bin/nanodlna", line 8, in
sys.exit(run())
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 150, in run
args.func(args)
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 55, in list_devices
my_devices = devices.get_devices(args.timeout)
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in get_devices
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 114, in
devices = [register_device(location_url) for location_url in devices_urls]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 40, in register_device
friendly_name = info.find("./device/friendlyName").text
AttributeError: 'NoneType' object has no attribute 'text'

Thank you!

Ok. If i comment this lines in devices.py:
# friendly_name = info.find("./device/friendlyName").text
# "friendly_name": friendly_name,

getting output:
nanodlna list
nano-dlna log will be saved here: /tmp/tmpxznjrsh7/nanodlna-2022-05-11_10-31-27.log
Device 1:
{
"location": "http://192.168.1.10:7676/smp_18_",
"hostname": "192.168.1.10",
"action_url": null,
"st": "urn:schemas-upnp-org:service:AVTransport:1"
}

Device 2:
{
"location": "http://192.168.1.10:7676/smp_18_",
"hostname": "192.168.1.10",
"action_url": null,
"st": "urn:schemas-upnp-org:service:AVTransport:1"
}

I dont know how works info.find("./device/friendlyName").text , may be getting dns name?

Thank you for the follow up @vansatchen!

I will think about adding service_identity as a dependency, or maybe disable this warning, since it would not affect us (we serve through http).

Regarding the other error, would you mind sharing the log file that is generated in the message after running nanodlna --debug list?

 nano-dlna log will be saved here: /tmp/tmpow_XXXXX/nanodlna-YYYYY.log

Thanks!

Oh, I forgot to register the content of the XML of the device in the logs. I will add that in the next version.

Meanwhile, could you share now the content of http://192.168.1.10:7676/smp_18_ ? It is a XML with information provided by your smart tv. You could do the following:

curl http://192.168.1.10:7676/smp_18_ > device.xml

And share the device.xml?

Thanks :)

Rename device.txt to device.xml, github doesnt allow share xmls )
device.txt

Hi @vansatchen.

I think I figured out what was happening. There was a preprocessing that I did on the XML that I was assuming the input would always come in double quotes, but in fact it can also be in single quotes (which is the case of your device).

I pulled this fix (together with other improvements) into the develop branch of the repository. Could you checkout it, install and test it for us?

Thanks!

Hi @gabrielmagno!
Nice job. Looks like bug is solved, thank you! :)

Now output:
nanodlna list
nano-dlna log will be saved here: /tmp/tmphpc5w9ah/nanodlna-2022-05-12_18-33-19.log
Device 1:
{
"location": "http://192.168.1.10:7676/smp_18_",
"hostname": "192.168.1.10",
"manufacturer": "Samsung Electronics",
"friendly_name": "[TV]UE40ES6307",
"action_url": "http://192.168.1.10:7676/smp_26_",
"st": "urn:schemas-upnp-org:service:AVTransport:1"
}

But after play some video, nanodlna list shows two devices again:
nanodlna list
nano-dlna log will be saved here: /tmp/tmplrbcjgfa/nanodlna-2022-05-12_18-51-51.log
Device 1:
{
"location": "http://192.168.1.10:7676/smp_18_",
"hostname": "192.168.1.10",
"manufacturer": "Samsung Electronics",
"friendly_name": "[TV]UE40ES6307",
"action_url": "http://192.168.1.10:7676/smp_26_",
"st": "urn:schemas-upnp-org:service:AVTransport:1"
}

Device 2:
{
"location": "http://192.168.1.10:7676/smp_18_",
"hostname": "192.168.1.10",
"manufacturer": "Samsung Electronics",
"friendly_name": "[TV]UE40ES6307",
"action_url": "http://192.168.1.10:7676/smp_26_",
"st": "urn:schemas-upnp-org:service:AVTransport:1"
}

log file from nanodlna --debug list attached.

nanodlna-2022-05-12_18-55-18.log

Hi @vansatchen.

Good to hear that it is working now! Have you tested playing video? Did it worked as well?

Regarding the duplicated device, that is not necessarily a problem, but I might do something to avoid that.

Hi @gabrielmagno!
Today strange error:
nanodlna --debug list
nano-dlna log will be saved here: /tmp/tmp9z67qu8r/nanodlna-2022-05-13_17-07-00.log
Traceback (most recent call last):
File "/usr/bin/nanodlna", line 8, in
sys.exit(run())
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 150, in run
args.func(args)
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 55, in list_devices
my_devices = devices.get_devices(args.timeout)
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 142, in get_devices
devices_urls = [dev["location"]
File "/usr/lib/python3.10/site-packages/nanodlna/devices.py", line 143, in
for dev in devices if "AVTransport" in dev["st"]]
KeyError: 'st'

Debug log attached.
nanodlna-2022-05-13_17-07-00.log

Also, if i try to play videos and images, first run is OK, playing as needed, but nanodlna not exit after playing. Output after ^C is:
Exception ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1560, in _shutdown
lock.acquire()
KeyboardInterrupt:

If i try to play other files, no reactions. I need to exit from tv player and after that new nanodlna play some.png shows as first time as above until ^C :)

Hi @vansatchen.

Did a couple of things:

  • Omit duplicated devices from the result
  • Check if st information of device exists before registering it
  • Handles SIGINT (including Ctrl + C), so that we send an STOP command to the render.

Could you pull the develop branch again, reinstall nano-dlna and check again?

Thanks :-)

Oh, forgot to comment about this:

but nanodlna not exit after playing

Sorry, currently nano-dlna will not be able to identify that the playing finished.
You will have to close it by hand.

Hi @gabrielmagno!
Now nanodlna list works without errors, thanks! ๐Ÿ‘

^C works, but looks like error:
nanodlna play some.jpg
nano-dlna log will be saved here: /tmp/tmpzjkb0int/nanodlna-2022-05-16_19-04-08.log
^CException ignored in: <module 'threading' from '/usr/lib/python3.10/threading.py'>
Traceback (most recent call last):
File "/usr/lib/python3.10/threading.py", line 1560, in _shutdown
lock.acquire()
File "/usr/lib/python3.10/site-packages/nanodlna/cli.py", line 145, in signal_handler
sys.exit(
SystemExit: Interrupt signal detected. Sent stop command to render device and stopped streaming. nano-dlna will exit now!

Anyway, its a very usefull app, thank you very much! :)

Yeah, I was not able to suppress that message. Will let it this way for now.

Thank you very much on helping me debug it @vansatchen.

As you know, the fixes area already in develop branch, and you can use it.
Eventually I will release a new version of nano-dlna to include these fixes and other modifications.

I will close the issue now.