From aabf30450ecc043663935e5ed84e958f81b9f133 Mon Sep 17 00:00:00 2001 From: Alex Yefremenko Date: Wed, 25 Oct 2017 11:09:46 -0400 Subject: [PATCH] Fix issue with concurrent import of plotly module and checking permissions --- plotly/files.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plotly/files.py b/plotly/files.py index 9668f144b13..d648a0b66ff 100644 --- a/plotly/files.py +++ b/plotly/files.py @@ -1,11 +1,10 @@ import os +from stat import ST_MODE, S_IWUSR, S_IRUSR # file structure PLOTLY_DIR = os.path.join(os.path.expanduser("~"), ".plotly") CREDENTIALS_FILE = os.path.join(PLOTLY_DIR, ".credentials") CONFIG_FILE = os.path.join(PLOTLY_DIR, ".config") -TEST_DIR = os.path.join(os.path.expanduser("~"), ".test") -TEST_FILE = os.path.join(PLOTLY_DIR, ".permission_test") # this sets both the DEFAULTS and the TYPES for these files FILE_CONTENT = {CREDENTIALS_FILE: {'username': '', @@ -25,14 +24,9 @@ def _permissions(): try: - os.mkdir(TEST_DIR) - os.rmdir(TEST_DIR) if not os.path.exists(PLOTLY_DIR): os.mkdir(PLOTLY_DIR) - with open(TEST_FILE, 'w') as f: - f.write('testing\n') - os.remove(TEST_FILE) - return True + return os.stat(PLOTLY_DIR)[ST_MODE] & (S_IWUSR | S_IRUSR) == (S_IWUSR | S_IRUSR) except: return False