Skip to content

Commit f8a7324

Browse files
committed
Insert new verification settings into requests.
1 parent 6b8d8a2 commit f8a7324

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

plotly/plotly/plotly.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):
360360
raise exceptions.PlotlyError(
361361
"The 'file_id' argument must be a non-negative number."
362362
)
363-
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'])
364366
if response.status_code == 200:
365367
if six.PY3:
366368
content = json.loads(response.content.decode('unicode_escape'))
@@ -580,10 +582,10 @@ def get(figure_or_data, format='png', width=None, height=None):
580582
payload['height'] = height
581583

582584
url = get_config()['plotly_domain'] + "/apigenimage/"
583-
res = requests.post(url,
584-
data=json.dumps(payload,
585-
cls=utils._plotlyJSONEncoder),
586-
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+
)
587589

588590
headers = res.headers
589591

@@ -683,7 +685,8 @@ def mkdirs(cls, folder_path):
683685

684686
url = _api_v2.api_url('folders')
685687

686-
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'])
687690

688691
_api_v2.response_handler(res)
689692

@@ -734,7 +737,8 @@ def upload(cls, grid, filename,
734737

735738
upload_url = _api_v2.api_url('grids')
736739
req = requests.post(upload_url, data=payload,
737-
headers=_api_v2.headers())
740+
headers=_api_v2.headers(),
741+
verify=get_config()['plotly_ssl_verification'])
738742

739743
res = _api_v2.response_handler(req)
740744

@@ -776,7 +780,8 @@ def append_columns(cls, columns, grid=None, grid_url=None):
776780
}
777781

778782
api_url = _api_v2.api_url('grids')+'/{grid_id}/col'.format(grid_id=grid_id)
779-
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'])
780785
res = _api_v2.response_handler(res)
781786

782787
cls._fill_in_response_column_ids(columns, res['cols'], grid_id)
@@ -808,7 +813,8 @@ def append_rows(cls, rows, grid=None, grid_url=None):
808813

809814
api_url = (_api_v2.api_url('grids')+
810815
'/{grid_id}/row'.format(grid_id=grid_id))
811-
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'])
812818
_api_v2.response_handler(res)
813819

814820
if grid:
@@ -827,7 +833,8 @@ def append_rows(cls, rows, grid=None, grid_url=None):
827833
def delete(cls, grid=None, grid_url=None):
828834
grid_id = _api_v2.parse_grid_id_args(grid, grid_url)
829835
api_url = _api_v2.api_url('grids')+'/'+grid_id
830-
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'])
831838
_api_v2.response_handler(res)
832839

833840

@@ -845,7 +852,8 @@ def upload(cls, meta, grid=None, grid_url=None):
845852

846853
api_url = _api_v2.api_url('grids')+'/{grid_id}'.format(grid_id=grid_id)
847854

848-
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'])
849857

850858
return _api_v2.response_handler(res)
851859

@@ -964,7 +972,8 @@ def _send_to_plotly(figure, **plot_options):
964972

965973
url = get_config()['plotly_domain'] + "/clientresp"
966974

967-
r = requests.post(url, data=payload)
975+
r = requests.post(url, data=payload,
976+
verify=get_config()['plotly_ssl_verification'])
968977
r.raise_for_status()
969978
r = json.loads(r.text)
970979
if 'error' in r and r['error'] != '':

0 commit comments

Comments
 (0)