You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ev3dev.Leds.set_color(ev3dev.Leds.LEFT, ev3dev.Leds.ORANGE)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ev3dev/ev3.py", line 76, in set_color
l.brightness_pct = v * pct
File "ev3dev/core.py", line 1688, in brightness_pct
self.brightness = value * self.max_brightness
File "ev3dev/core.py", line 1606, in max_brightness
return self.get_attr_int('max_brightness')
File "ev3dev/core.py", line 169, in get_attr_int
return int(self._get_attribute(attribute))
File "ev3dev/core.py", line 162, in _get_attribute
return self._attribute_cache.read(abspath(self._path + '/' + attribute))
File "ev3dev/core.py", line 82, in read
f = self.file_handle(path)
File "ev3dev/core.py", line 74, in file_handle
f = open(path, mode, 0)
IOError: [Errno 13] Permission denied: '/sys/class/leds/ev3-left0:red:ev3dev/max_brightness'
I guess we could revert #73, and check that IOError here is actually a 'wrong mode' error (and rethrow exception otherwise). The only problem is I could not come up with a way to do this reliably.
Can we use os.stat() and check st_mode? I gave it a quick try, but I am missing something:
import os
from stat import *
mode=os.stat('/sys/class/leds/ev3-left0:red:ev3dev/max_brightness').st_mode
S_IWUSR(mode)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'int' object is not callable
importstat, osst=os.stat('test.txt')
mode=stat.S_IMODE(st[stat.ST_MODE])
stat.S_IRGRP&mode# is file readable by group?stat.S_IWGRP&mode# is file writable by group?
This sounds good to me. This is on develop, so this will become 0.5.1? Since it is a bugfix and not an API break, I think it should be in master for 0.5.0.
Activity
ensonic commentedon Nov 7, 2015
Apparently, the "Permission denied" only happens for root.
[-]leds api defunct[/-][+]leds api defunct (for root)[/+]ddemidov commentedon Nov 7, 2015
I guess we could revert #73, and check that IOError here is actually a 'wrong mode' error (and rethrow exception otherwise). The only problem is I could not come up with a way to do this reliably.
ensonic commentedon Nov 7, 2015
Can we use os.stat() and check st_mode? I gave it a quick try, but I am missing something:
ddemidov commentedon Nov 8, 2015
That actually could work, thanks!
I'll do a PR in a couple of hours.
rhempel commentedon Nov 8, 2015
I merged this PR, but it occurs to me that this is just checking for
groupprivileges.Don't we want to check if the file is read/writeable by
userORgroupORworldddemidov commentedon Nov 8, 2015
Users only get access to sysfs attributes because they are in ev3dev group. I thought that checking for group access is only right.
rhempel commentedon Nov 8, 2015
OK, as long as all the attributes we ever create have
ev3devgroup ownership then I'm OK with the change as is.rhempel commentedon Nov 8, 2015
Sorry, @ensonic should close - on Monday
ensonic commentedon Nov 9, 2015
This sounds good to me. This is on develop, so this will become 0.5.1? Since it is a bugfix and not an API break, I think it should be in master for 0.5.0.
rhempel commentedon Nov 9, 2015
Agreed - I'm on a business trip and have limited time - plus my power adapter is failing. I'l do my best to merge develop into master and tag 0.5.0.