From f49158b93aef7eb312de7da5f45a7606384e1fbe Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Sun, 8 Nov 2015 10:46:28 +0300 Subject: [PATCH] Use os.stat instead of os.access This gives true file permissions irregardless of the current user. Fixes #84 --- ev3dev/core.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ev3dev/core.py b/ev3dev/core.py index 6092fe9..247f770 100644 --- a/ev3dev/core.py +++ b/ev3dev/core.py @@ -36,6 +36,7 @@ import mmap import ctypes import re +import stat from os.path import abspath from PIL import Image, ImageDraw from struct import pack, unpack @@ -58,8 +59,10 @@ def file_handle(self, path, binary=False): """Manages the file handle cache and opening the files in the correct mode""" if path not in self._cache: - r_ok = os.access(path, os.R_OK) - w_ok = os.access(path, os.W_OK) + mode = stat.S_IMODE(os.stat(path)[stat.ST_MODE]) + + r_ok = mode & stat.S_IRGRP + w_ok = mode & stat.S_IWGRP if r_ok and w_ok: mode = 'a+'