summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-11-03 18:13:20 +0000
committerGerrit Code Review <review@openstack.org>2015-11-03 18:13:20 +0000
commit40126a4040bb98cb362161399f2bea0800af704a (patch)
treea196e0b35c4ed665dfb96d0d805301fb98cf0b16
parent9b2d963d039a6499a1fc3a51bf29225492f08417 (diff)
parent448d4697803ad6993d81ca556a63977f1c039a7f (diff)
Merge "Add SubjectAltNameWarning and a helper function"1.1.0
-rw-r--r--requestsexceptions/__init__.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/requestsexceptions/__init__.py b/requestsexceptions/__init__.py
index aefb002..f1c1e50 100644
--- a/requestsexceptions/__init__.py
+++ b/requestsexceptions/__init__.py
@@ -12,6 +12,8 @@
12# License for the specific language governing permissions and limitations 12# License for the specific language governing permissions and limitations
13# under the License. 13# under the License.
14 14
15import warnings
16
15try: 17try:
16 from requests.packages.urllib3.exceptions import InsecurePlatformWarning 18 from requests.packages.urllib3.exceptions import InsecurePlatformWarning
17except ImportError: 19except ImportError:
@@ -27,3 +29,20 @@ except ImportError:
27 from urllib3.exceptions import InsecureRequestWarning 29 from urllib3.exceptions import InsecureRequestWarning
28 except ImportError: 30 except ImportError:
29 InsecureRequestWarning = None 31 InsecureRequestWarning = None
32
33try:
34 from requests.packages.urllib3.exceptions import SubjectAltNameWarning
35except ImportError:
36 try:
37 from urllib3.exceptions import SubjectAltNameWarning
38 except ImportError:
39 SubjectAltNameWarning = None
40
41
42def squelch_warnings(insecure_requests=True):
43 if SubjectAltNameWarning:
44 warnings.filterwarnings('ignore', category=SubjectAltNameWarning)
45 if InsecurePlatformWarning:
46 warnings.filterwarnings('ignore', category=InsecurePlatformWarning)
47 if insecure_requests and InsecureRequestWarning):
48 warnings.filterwarnings('ignore', category=InsecureRequestWarning)