@@ -67,6 +67,7 @@ def sign_in(username, api_key, **kwargs):
6767 _config ['plotly_domain' ] = kwargs .get ('plotly_domain' )
6868 _config ['plotly_streaming_domain' ] = kwargs .get ('plotly_streaming_domain' )
6969 _config ['plotly_api_domain' ] = kwargs .get ('plotly_api_domain' )
70+ _config ['plotly_ssl_verification' ] = kwargs .get ('plotly_ssl_verification' )
7071 # TODO: verify format of config options
7172
7273
@@ -141,7 +142,7 @@ def get_config():
141142 """Returns either module config or file config."""
142143 config = tools .get_config_file ()
143144 for config_key in config :
144- if _config .get (config_key ):
145+ if _config .get (config_key ) is not None :
145146 config [config_key ] = _config [config_key ]
146147 return config
147148
@@ -359,7 +360,9 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
359360 raise exceptions .PlotlyError (
360361 "The 'file_id' argument must be a non-negative number."
361362 )
362- response = requests .get (plotly_rest_url + resource , headers = headers )
363+ response = requests .get (plotly_rest_url + resource ,
364+ headers = headers ,
365+ verify = get_config ()['plotly_ssl_verification' ])
363366 if response .status_code == 200 :
364367 if six .PY3 :
365368 content = json .loads (response .content .decode ('unicode_escape' ))
@@ -579,10 +582,10 @@ def get(figure_or_data, format='png', width=None, height=None):
579582 payload ['height' ] = height
580583
581584 url = get_config ()['plotly_domain' ] + "/apigenimage/"
582- res = requests .post (url ,
583- data = json .dumps (payload ,
584- cls = utils . _plotlyJSONEncoder ),
585- headers = headers )
585+ res = requests .post (
586+ url , data = json .dumps (payload , cls = utils . _plotlyJSONEncoder ) ,
587+ headers = headers , verify = get_config ()[ 'plotly_ssl_verification' ]
588+ )
586589
587590 headers = res .headers
588591
@@ -682,7 +685,8 @@ def mkdirs(cls, folder_path):
682685
683686 url = _api_v2 .api_url ('folders' )
684687
685- res = requests .post (url , data = payload , headers = _api_v2 .headers ())
688+ res = requests .post (url , data = payload , headers = _api_v2 .headers (),
689+ verify = get_config ()['plotly_ssl_verification' ])
686690
687691 _api_v2 .response_handler (res )
688692
@@ -733,7 +737,8 @@ def upload(cls, grid, filename,
733737
734738 upload_url = _api_v2 .api_url ('grids' )
735739 req = requests .post (upload_url , data = payload ,
736- headers = _api_v2 .headers ())
740+ headers = _api_v2 .headers (),
741+ verify = get_config ()['plotly_ssl_verification' ])
737742
738743 res = _api_v2 .response_handler (req )
739744
@@ -775,7 +780,8 @@ def append_columns(cls, columns, grid=None, grid_url=None):
775780 }
776781
777782 api_url = _api_v2 .api_url ('grids' )+ '/{grid_id}/col' .format (grid_id = grid_id )
778- res = requests .post (api_url , data = payload , headers = _api_v2 .headers ())
783+ res = requests .post (api_url , data = payload , headers = _api_v2 .headers (),
784+ verify = get_config ()['plotly_ssl_verification' ])
779785 res = _api_v2 .response_handler (res )
780786
781787 cls ._fill_in_response_column_ids (columns , res ['cols' ], grid_id )
@@ -807,7 +813,8 @@ def append_rows(cls, rows, grid=None, grid_url=None):
807813
808814 api_url = (_api_v2 .api_url ('grids' )+
809815 '/{grid_id}/row' .format (grid_id = grid_id ))
810- res = requests .post (api_url , data = payload , headers = _api_v2 .headers ())
816+ res = requests .post (api_url , data = payload , headers = _api_v2 .headers (),
817+ verify = get_config ()['plotly_ssl_verification' ])
811818 _api_v2 .response_handler (res )
812819
813820 if grid :
@@ -826,7 +833,8 @@ def append_rows(cls, rows, grid=None, grid_url=None):
826833 def delete (cls , grid = None , grid_url = None ):
827834 grid_id = _api_v2 .parse_grid_id_args (grid , grid_url )
828835 api_url = _api_v2 .api_url ('grids' )+ '/' + grid_id
829- res = requests .delete (api_url , headers = _api_v2 .headers ())
836+ res = requests .delete (api_url , headers = _api_v2 .headers (),
837+ verify = get_config ()['plotly_ssl_verification' ])
830838 _api_v2 .response_handler (res )
831839
832840
@@ -844,7 +852,8 @@ def upload(cls, meta, grid=None, grid_url=None):
844852
845853 api_url = _api_v2 .api_url ('grids' )+ '/{grid_id}' .format (grid_id = grid_id )
846854
847- res = requests .patch (api_url , data = payload , headers = _api_v2 .headers ())
855+ res = requests .patch (api_url , data = payload , headers = _api_v2 .headers (),
856+ verify = get_config ()['plotly_ssl_verification' ])
848857
849858 return _api_v2 .response_handler (res )
850859
@@ -963,7 +972,8 @@ def _send_to_plotly(figure, **plot_options):
963972
964973 url = get_config ()['plotly_domain' ] + "/clientresp"
965974
966- r = requests .post (url , data = payload )
975+ r = requests .post (url , data = payload ,
976+ verify = get_config ()['plotly_ssl_verification' ])
967977 r .raise_for_status ()
968978 r = json .loads (r .text )
969979 if 'error' in r and r ['error' ] != '' :
0 commit comments