ci: fixing linter error

Fixing linter error (using variable 'urllib' before assignment)
Adding logic to properly import urlencode depending on python version

closes: https://github.com/rook/rook/issues/12985

Signed-off-by: Redouane Kachach <rkachach@redhat.com>
This commit is contained in:
Redouane Kachach committed 2023-10-04 09:40:49 +02:00
1 parent eb71fb2b65
commit aa59e3bb86
1 file changed
+3 -1
@@ -58,9 +58,11 @@ except ModuleNotFoundError:
try:
# for 2.7.x
from urlparse import urlparse
from urllib import urlencode as urlencode
except ModuleNotFoundError:
# for 3.x
from urllib.parse import urlparse
from urllib.parse import urlencode as urlencode
try:
from base64 import encodestring
@@ -1363,7 +1365,7 @@ class RadosJSON:
rgw_endpoint = self._arg_parser.rgw_endpoint
base_url = base_url + "://" + rgw_endpoint + "/admin/info?"
params = {"format": "json"}
request_url = base_url + urllib.parse.urlencode(params)
request_url = base_url + urlencode(params)
try:
r = requests.get(