From 97ca9641822129deea03f3ad7691bae146b67560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20M=C3=A9ndez=20Hern=C3=A1ndez?= Date: Thu, 21 Dec 2023 14:07:30 +0100 Subject: [PATCH] fix(cluster_read.py): Disable `InsecureRequestWarning` properly Using `requests >= 2.16.0` this is the proper way to disable that warning --- opl/cluster_read.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/opl/cluster_read.py b/opl/cluster_read.py index 6aec75b..b8104f0 100755 --- a/opl/cluster_read.py +++ b/opl/cluster_read.py @@ -10,8 +10,7 @@ import jinja2 import jinja2.exceptions import boto3 - -from requests.packages.urllib3.exceptions import InsecureRequestWarning +import urllib3 from . import data from . import date @@ -115,7 +114,7 @@ def measure(self, ri, name, monitoring_query, monitoring_step): "start": ri.start.timestamp(), "end": ri.end.timestamp(), } - requests.packages.urllib3.disable_warnings(InsecureRequestWarning) + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) response = requests.get( url, headers=headers, params=params, verify=False, timeout=60 ) @@ -200,6 +199,7 @@ def measure(self, ri, name, grafana_target): } url = f"{self.args.grafana_host}:{self.args.grafana_port}/api/datasources/proxy/{self.args.grafana_datasource}/render" + urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) r = requests.post( url=url, headers=headers, params=params, timeout=60, verify=False )