From c6255c87bd92cc724afb995af826f1e2399c82ff Mon Sep 17 00:00:00 2001 From: GeorgianaElena Date: Wed, 29 May 2019 12:35:19 +0300 Subject: [PATCH] Suppress insecure HTTPS warning when upgrading TLJH --- tljh/installer.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tljh/installer.py b/tljh/installer.py index ba44bfb..fcee24f 100644 --- a/tljh/installer.py +++ b/tljh/installer.py @@ -8,9 +8,11 @@ import secrets import subprocess import sys import time +import warnings import pluggy import requests +from requests.packages.urllib3.exceptions import InsecureRequestWarning from tljh import ( apt, @@ -292,8 +294,11 @@ def ensure_jupyterhub_running(times=20): for i in range(times): try: logger.info('Waiting for JupyterHub to come up ({}/{} tries)'.format(i + 1, times)) - # We don't care at this level that SSL is valid - requests.get('http://127.0.0.1', verify=False) + # 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) return except requests.HTTPError as h: if h.response.status_code in [404, 502, 503]: