Skip to content

Commit f49158b

Browse files
committed
Use os.stat instead of os.access
This gives true file permissions irregardless of the current user. Fixes #84
1 parent 7f78d6c commit f49158b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ev3dev/core.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import mmap
3737
import ctypes
3838
import re
39+
import stat
3940
from os.path import abspath
4041
from PIL import Image, ImageDraw
4142
from struct import pack, unpack
@@ -58,8 +59,10 @@ def file_handle(self, path, binary=False):
5859
"""Manages the file handle cache and opening the files in the correct mode"""
5960

6061
if path not in self._cache:
61-
r_ok = os.access(path, os.R_OK)
62-
w_ok = os.access(path, os.W_OK)
62+
mode = stat.S_IMODE(os.stat(path)[stat.ST_MODE])
63+
64+
r_ok = mode & stat.S_IRGRP
65+
w_ok = mode & stat.S_IWGRP
6366

6467
if r_ok and w_ok:
6568
mode = 'a+'

0 commit comments

Comments
 (0)