Suppress insecure HTTPS warning when upgrading TLJH

This commit is contained in:
GeorgianaElena
2019-05-29 12:35:19 +03:00
parent cebeff736f
commit c6255c87bd

View File

@@ -8,9 +8,11 @@ import secrets
import subprocess import subprocess
import sys import sys
import time import time
import warnings
import pluggy import pluggy
import requests import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
from tljh import ( from tljh import (
apt, apt,
@@ -292,7 +294,10 @@ def ensure_jupyterhub_running(times=20):
for i in range(times): for i in range(times):
try: try:
logger.info('Waiting for JupyterHub to come up ({}/{} tries)'.format(i + 1, times)) logger.info('Waiting for JupyterHub to come up ({}/{} tries)'.format(i + 1, times))
# We don't care at this level that SSL is valid # Because we don't care at this level that SSL is valid, we can suppress
# InsecureRequestWarning for this request.
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=InsecureRequestWarning)
requests.get('http://127.0.0.1', verify=False) requests.get('http://127.0.0.1', verify=False)
return return
except requests.HTTPError as h: except requests.HTTPError as h: