vmware_tools: ignore absence of urllib3

This commit is contained in:
James Cassell 2019-04-11 15:09:29 -04:00 committed by Toshio Kuratomi
parent f40778cae3
commit 05fe9ef816

View file

@ -10,9 +10,16 @@ from os.path import exists, getsize
from socket import gaierror from socket import gaierror
from ssl import SSLError from ssl import SSLError
from time import sleep from time import sleep
import urllib3
import traceback import traceback
URLLIB3_IMP_ERR = None
try:
import urllib3
HAS_URLLIB3 = True
except ImportError:
URLLIB3_IMP_ER = traceback.format_exc()
HAS_URLLIB3 = False
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
import requests import requests
@ -290,7 +297,7 @@ class Connection(ConnectionBase):
if self.validate_certs: if self.validate_certs:
connect = SmartConnect connect = SmartConnect
else: else:
if self.get_option("silence_tls_warnings"): if HAS_URLLIB3 and self.get_option("silence_tls_warnings"):
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
connect = SmartConnectNoSSL connect = SmartConnectNoSSL