Autoconnect for udisks2 plug for Thonny

Thonny a python IDE needs udisks2 plug without it the program has few functions not working properly. Here are some logs etc.

Traceback (most recent call last):
  File "/snap/thonny/27/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/snap/thonny/27/lib/python3.10/site-packages/thonny/workbench.py", line 861, in _post_backend_menu
    if uf2_device_is_present_in_bootloader_mode():
  File "/snap/thonny/27/lib/python3.10/site-packages/thonny/plugins/micropython/uf2dialog.py", line 249, in uf2_device_is_present_in_bootloader_mode
    for vol in list_volumes(skip_letters=["A"]):
  File "/snap/thonny/27/lib/python3.10/site-packages/thonny/misc_utils.py", line 105, in list_volumes
    mount_points = list_volumes_sync()
  File "/snap/thonny/27/lib/python3.10/site-packages/thonny/udisks.py", line 19, in list_volumes_sync
    return loop.run_until_complete(list_volumes())
  File "/snap/thonny/27/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/snap/thonny/27/lib/python3.10/site-packages/thonny/udisks.py", line 44, in list_volumes
    block_devices = await interface.call_get_block_devices({})
  File "/snap/thonny/27/lib/python3.10/site-packages/dbus_next/aio/proxy_object.py", line 92, in method_fn
    BaseProxyInterface._check_method_return(msg, intr_method.out_signature)
  File "/snap/thonny/27/lib/python3.10/site-packages/dbus_next/proxy_object.py", line 62, in _check_method_return
    raise DBusError._from_message(msg)
dbus_next.errors.DBusError: An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender=":1.167" (uid=1000 pid=28390 comm="/snap/thonny/27/bin/python3.10 -I -m thonny " label="snap.thonny.thonny (enforce)") interface="org.freedesktop.UDisks2.Manager" member="GetBlockDevices" error name="(unset)" requested_reply="0" destination="org.freedesktop.UDisks2" (uid=0 pid=1286 comm="/usr/libexec/udisks2/udisksd " label="unconfined")

After manually adding the plug it doesn’t happen.

Few thing to highlight need of this plug by thonny snap ;

  1. https://github.com/thonny/thonny/pull/2683

  2. https://github.com/CapeCrusader321/Thonny-Snap/issues/2

  3. https://github.com/thonny/thonny/issues/2650

  4. https://github.com/thonny/thonny/issues/2650

  5. https://github.com/thonny/thonny/issues/2692

Plus snappy-debug also recommends the plug, if this plug cant be granted any alternate solution to fix this will be fine. Thanks

Can you describe what thonny is using udisks2 for? It would help to know if this is a normal use-case for all / most users of thonny or just some.

Yes sure, i will update you soon after i ask the same in detail from the thonny devs

Please See --> https://github.com/thonny/thonny/issues/2803

This is the main reason as per the devs, from my side in the snap variant if the absence of this plug also causes some more issues than expected, like one is unable to access to choose the interpreter path etc.

heh, this is sad, i remember it working fine with the older thonny in my personal snap just utilizing the mount-observe interface … seems flatpak can’t do this which made them change the code to use udisks, so now the snap needs it too instead of the simpler call to mount

Maybe, the one i build by forking yours previously had everything working fine but now it may need some changes ??

yes, mine used an old upstream tarball that is definitely not recent anymore… the new code that was adjusted for flatpak support will likely now need udisks

thanks for the updated information - +1 from me for auto-connect of udisks2 for thonny.

the explanation from upstream makes sense, +1 from me for thonny to auto-connect udisks2

That’s 2 votes for, 0 against. Granting auto-connect of udisks2 to thonny. This is now live.

Thanks, closing this