I would like to get group of directory. I tried answers from this question, but neither work for me.
If I list file trough terminal I get correct group gpio.
$ ls -l /sys/class/gpio/
total 0
--w--w---- 1 root gpio 4096 Feb 26 15:07 export
lrwxrwxrwx 1 root gpio 0 Feb 26 15:07 gpio248 -> ../../devices/6000d000.gpio/gpiochip0/gpio/gpio248
lrwxrwxrwx 1 root gpio 0 Feb 26 14:19 gpio250 -> ../../devices/6000d000.gpio/gpiochip0/gpio/gpio250
lrwxrwxrwx 1 root gpio 0 Feb 26 14:35 gpio252 -> ../../devices/6000d000.gpio/gpiochip0/gpio/gpio252
lrwxrwxrwx 1 root gpio 0 Feb 26 13:45 gpiochip0 -> ../../devices/6000d000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio 0 Feb 26 13:45 gpiochip504 -> ../../devices/7000d000.i2c/i2c-4/4-003c/max77620-gpio/gpio/gpiochip504
--w--w---- 1 root gpio 4096 Feb 26 13:58 unexport
If I do a same with a python, I get correct user and wrong group.
>>> import pathlib
>>> src = "/sys/class/gpio/gpio252"
>>>
>>> pth = pathlib.Path(src)
>>>
>>> pth.group()
'root'
>>> pth.owner()
'root'
>>>
I tried it on Python version 3.6.9 and 3.9.2, both with and without virtual environment.
I have a UDEV rule that corrects a group of newly created gpio's with chown command. But it takes some time, so I want to wait for it in my code, but I do not want use a fixed timer.
Thank You any advice