@@ -67,6 +67,7 @@ def sign_in(username, api_key, **kwargs):
67
67
_config ['plotly_domain' ] = kwargs .get ('plotly_domain' )
68
68
_config ['plotly_streaming_domain' ] = kwargs .get ('plotly_streaming_domain' )
69
69
_config ['plotly_api_domain' ] = kwargs .get ('plotly_api_domain' )
70
+ _config ['plotly_ssl_verification' ] = kwargs .get ('plotly_ssl_verification' )
70
71
# TODO: verify format of config options
71
72
72
73
@@ -141,7 +142,7 @@ def get_config():
141
142
"""Returns either module config or file config."""
142
143
config = tools .get_config_file ()
143
144
for config_key in config :
144
- if _config .get (config_key ):
145
+ if _config .get (config_key ) is not None :
145
146
config [config_key ] = _config [config_key ]
146
147
return config
147
148
@@ -359,7 +360,9 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
359
360
raise exceptions .PlotlyError (
360
361
"The 'file_id' argument must be a non-negative number."
361
362
)
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' ])
363
366
if response .status_code == 200 :
364
367
if six .PY3 :
365
368
content = json .loads (response .content .decode ('unicode_escape' ))
@@ -579,10 +582,10 @@ def get(figure_or_data, format='png', width=None, height=None):
579
582
payload ['height' ] = height
580
583
581
584
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
+ )
586
589
587
590
headers = res .headers
588
591
@@ -682,7 +685,8 @@ def mkdirs(cls, folder_path):
682
685
683
686
url = _api_v2 .api_url ('folders' )
684
687
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' ])
686
690
687
691
_api_v2 .response_handler (res )
688
692
@@ -733,7 +737,8 @@ def upload(cls, grid, filename,
733
737
734
738
upload_url = _api_v2 .api_url ('grids' )
735
739
req = requests .post (upload_url , data = payload ,
736
- headers = _api_v2 .headers ())
740
+ headers = _api_v2 .headers (),
741
+ verify = get_config ()['plotly_ssl_verification' ])
737
742
738
743
res = _api_v2 .response_handler (req )
739
744
@@ -775,7 +780,8 @@ def append_columns(cls, columns, grid=None, grid_url=None):
775
780
}
776
781
777
782
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' ])
779
785
res = _api_v2 .response_handler (res )
780
786
781
787
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):
807
813
808
814
api_url = (_api_v2 .api_url ('grids' )+
809
815
'/{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' ])
811
818
_api_v2 .response_handler (res )
812
819
813
820
if grid :
@@ -826,7 +833,8 @@ def append_rows(cls, rows, grid=None, grid_url=None):
826
833
def delete (cls , grid = None , grid_url = None ):
827
834
grid_id = _api_v2 .parse_grid_id_args (grid , grid_url )
828
835
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' ])
830
838
_api_v2 .response_handler (res )
831
839
832
840
@@ -844,7 +852,8 @@ def upload(cls, meta, grid=None, grid_url=None):
844
852
845
853
api_url = _api_v2 .api_url ('grids' )+ '/{grid_id}' .format (grid_id = grid_id )
846
854
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' ])
848
857
849
858
return _api_v2 .response_handler (res )
850
859
@@ -963,7 +972,8 @@ def _send_to_plotly(figure, **plot_options):
963
972
964
973
url = get_config ()['plotly_domain' ] + "/clientresp"
965
974
966
- r = requests .post (url , data = payload )
975
+ r = requests .post (url , data = payload ,
976
+ verify = get_config ()['plotly_ssl_verification' ])
967
977
r .raise_for_status ()
968
978
r = json .loads (r .text )
969
979
if 'error' in r and r ['error' ] != '' :
0 commit comments