Skip to content

Commit 5271fcc

Browse files
committed
check that share key is enabled
1 parent 1e686cf commit 5271fcc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

Diff for: plotly/plotly/plotly.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1295,9 +1295,9 @@ def parse_grid_id_args(grid, grid_url):
12951295
return grid.id
12961296

12971297

1298-
def add_share_key_to_url(plot_url):
1298+
def add_share_key_to_url(plot_url, attempt=0):
12991299
"""
1300-
Update plot's url to include the secret key
1300+
Check that share key is enabled and update url to include the secret key
13011301
13021302
"""
13031303
urlsplit = six.moves.urllib.parse.urlparse(plot_url)
@@ -1308,7 +1308,14 @@ def add_share_key_to_url(plot_url):
13081308
body = {'share_key_enabled': True, 'world_readable': False}
13091309
response = v2.files.update(fid, body)
13101310

1311-
return plot_url + '?share_key=' + response.json()['share_key']
1311+
if not v2.files.retrieve(fid).json()['share_key_enabled']:
1312+
attempt += 1
1313+
if attempt == 10:
1314+
raise Exception
1315+
add_share_key_to_url(plot_url, attempt)
1316+
1317+
url_share_key = plot_url + '?share_key=' + response.json()['share_key']
1318+
return url_share_key
13121319

13131320

13141321
def _send_to_plotly(figure, **plot_options):

0 commit comments

Comments
 (0)