From 71bf886dabc97cf733282cf3fcd9cdba601e83bd Mon Sep 17 00:00:00 2001 From: subhamkrai Date: Wed, 7 Sep 2022 16:24:04 +0530 Subject: [PATCH] external: fix import errors for python2 remove duplicate import urllib.parse which is handled below with try and except no need to import separately. Also, change the way to get the python version. Signed-off-by: subhamkrai (cherry picked from commit 9a952df419f8d9273e695bff3557986f82e6e166) --- deploy/examples/create-external-cluster-resources.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/deploy/examples/create-external-cluster-resources.py b/deploy/examples/create-external-cluster-resources.py index fa84051d1..c13b11ac8 100644 --- a/deploy/examples/create-external-cluster-resources.py +++ b/deploy/examples/create-external-cluster-resources.py @@ -25,11 +25,14 @@ from hashlib import sha1 as sha from os import linesep as LINESEP from os import path from email.utils import formatdate -import urllib.parse - import requests from requests.auth import AuthBase +py3k = False +if sys.version_info.major >= 3: + py3k = True + import urllib.parse + ModuleNotFoundError = ImportError try: @@ -58,13 +61,9 @@ except ModuleNotFoundError: # for 3.x from urllib.parse import urlparse -py3k = False try: - from urlparse import urlparse from base64 import encodestring except: - py3k = True - from urllib.parse import urlparse from base64 import encodebytes as encodestring