Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 09a9a8c

Browse files
committed
Made warning message nicer about file permissions, added dir check.
1 parent dccd3ee commit 09a9a8c

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

plotly/tools.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
PLOTLY_DIR = os.path.join(os.path.expanduser("~"), ".plotly")
2424
CREDENTIALS_FILE = os.path.join(PLOTLY_DIR, ".credentials")
2525
CONFIG_FILE = os.path.join(PLOTLY_DIR, ".config")
26+
TEST_DIR = os.path.join(os.path.expanduser("~"), ".test")
2627
TEST_FILE = os.path.join(PLOTLY_DIR, ".permission_test")
2728

2829
# this sets both the DEFAULTS and the TYPES for these items
@@ -33,6 +34,8 @@
3334
'plotly_streaming_domain': u'stream.plot.ly'}}
3435

3536
try:
37+
os.mkdir(TEST_DIR)
38+
os.rmdir(TEST_DIR)
3639
if not os.path.exists(PLOTLY_DIR):
3740
os.mkdir(PLOTLY_DIR)
3841
f = open(TEST_FILE, 'w')
@@ -64,10 +67,13 @@ def ensure_local_plotly_files():
6467
del contents[key]
6568
utils.save_json_dict(fn, contents)
6669
else:
67-
warnings.warn("Looks like you don't have 'write' permission. That "
68-
"means, plotly's python api can't setup local "
69-
"configuration files. No problem though! You'll just "
70-
"have to sign-in using 'plotly.sign_in'.")
70+
warnings.warn("Looks like you don't have 'read-write' permission to "
71+
"your 'home' ('~') directory or to our '~/.plotly' "
72+
"directory. That means plotly's python api can't setup "
73+
"local configuration files. No problem though! You'll "
74+
"just have to sign-in using 'plotly.sign_in()'. For help "
75+
"with that: 'help(plotly.sign_in)'."
76+
"\nQuestions? [email protected]")
7177

7278

7379
### credentials tools ###

0 commit comments

Comments
 (0)