49
49
ALTERNATIVE_HISTNORM = 'probability'
50
50
51
51
52
+ http_msg = (
53
+ "The plotly_domain and plotly_api_domain of your config file must start "
54
+ "with 'https', 'http'.\n If you are not using On-Prem then run the "
55
+ "following code to ensure your plotly_domain and plotly_api_domain start "
56
+ "with 'https':\n \n \n "
57
+ "import plotly\n "
58
+ "plotly.tools.set_config_file(\n "
59
+ " plotly_domain='https://plot.ly',\n "
60
+ " plotly_api_domain='https://api.plot.ly'\n "
61
+ ")\n \n \n "
62
+ "If you are using On-Prem then you will need to use your company's "
63
+ "domain and api_domain urls:\n \n \n "
64
+ "import plotly\n "
65
+ "plotly.tools.set_config_file(\n "
66
+ " plotly_domain='https://plotly.your-company.com',\n "
67
+ " plotly_api_domain='https://plotly.your-company.com'\n "
68
+ ")\n \n \n "
69
+ "Make sure to replace `your-company.com` with the URL of your Plotly "
70
+ "On-Premise server.\n See "
71
+ "https://plot.ly/python/getting-started/#special-instructions-for-plotly-onpremise-users "
72
+ "for more help with getting started with On-Prem."
73
+ )
74
+
75
+
76
+ def validate_config_file (* domains ):
77
+ for d in domains :
78
+ if not d .lower ().startswith ('https' ):
79
+ warnings .warn (http_msg )
80
+
81
+
52
82
# Warning format
53
83
def warning_on_one_line (message , category , filename , lineno ,
54
84
file = None , line = None ):
@@ -194,6 +224,7 @@ def set_config_file(plotly_domain=None,
194
224
'sharing' : sharing , 'world_readable' : world_readable })
195
225
settings = get_config_file ()
196
226
if isinstance (plotly_domain , six .string_types ):
227
+ validate_config_file (plotly_domain )
197
228
settings ['plotly_domain' ] = plotly_domain
198
229
elif plotly_domain is not None :
199
230
raise TypeError ('plotly_domain should be a string' )
@@ -202,6 +233,7 @@ def set_config_file(plotly_domain=None,
202
233
elif plotly_streaming_domain is not None :
203
234
raise TypeError ('plotly_streaming_domain should be a string' )
204
235
if isinstance (plotly_api_domain , six .string_types ):
236
+ validate_config_file (plotly_api_domain )
205
237
settings ['plotly_api_domain' ] = plotly_api_domain
206
238
elif plotly_api_domain is not None :
207
239
raise TypeError ('plotly_api_domain should be a string' )
@@ -244,9 +276,10 @@ def get_config_file(*args):
244
276
"""
245
277
if check_file_permissions ():
246
278
ensure_local_plotly_files () # make sure what's there is OK
247
- return utils .load_json_dict (CONFIG_FILE , * args )
279
+ returned_obj = utils .load_json_dict (CONFIG_FILE , * args )
248
280
else :
249
- return FILE_CONTENT [CONFIG_FILE ]
281
+ returned_obj = FILE_CONTENT [CONFIG_FILE ]
282
+ return returned_obj
250
283
251
284
252
285
def reset_config_file ():
0 commit comments