4949ALTERNATIVE_HISTNORM = 'probability'
5050
5151
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+
5282# Warning format
5383def warning_on_one_line (message , category , filename , lineno ,
5484 file = None , line = None ):
@@ -194,6 +224,7 @@ def set_config_file(plotly_domain=None,
194224 'sharing' : sharing , 'world_readable' : world_readable })
195225 settings = get_config_file ()
196226 if isinstance (plotly_domain , six .string_types ):
227+ validate_config_file (plotly_domain )
197228 settings ['plotly_domain' ] = plotly_domain
198229 elif plotly_domain is not None :
199230 raise TypeError ('plotly_domain should be a string' )
@@ -202,6 +233,7 @@ def set_config_file(plotly_domain=None,
202233 elif plotly_streaming_domain is not None :
203234 raise TypeError ('plotly_streaming_domain should be a string' )
204235 if isinstance (plotly_api_domain , six .string_types ):
236+ validate_config_file (plotly_api_domain )
205237 settings ['plotly_api_domain' ] = plotly_api_domain
206238 elif plotly_api_domain is not None :
207239 raise TypeError ('plotly_api_domain should be a string' )
@@ -244,9 +276,10 @@ def get_config_file(*args):
244276 """
245277 if check_file_permissions ():
246278 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 )
248280 else :
249- return FILE_CONTENT [CONFIG_FILE ]
281+ returned_obj = FILE_CONTENT [CONFIG_FILE ]
282+ return returned_obj
250283
251284
252285def reset_config_file ():
0 commit comments