mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
Fix undefined variables, basestring usage, and some associated python3 issues
This commit is contained in:
@@ -107,7 +107,8 @@ def retry(retries=None, retry_pause=1):
|
||||
if retries is not None:
|
||||
ret = None
|
||||
while True:
|
||||
retry_count += 1
|
||||
# pylint doesn't understand this is a closure
|
||||
retry_count += 1 # pylint: disable=undefined-variable
|
||||
if retry_count >= retries:
|
||||
raise Exception("Retry limit exceeded: %d" % retries)
|
||||
try:
|
||||
|
||||
@@ -24,7 +24,7 @@ except ImportError:
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.error import HTTPError
|
||||
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.api import basic_auth_argument_spec
|
||||
from ansible.module_utils.urls import open_url
|
||||
from ansible.module_utils.api import basic_auth_argument_spec
|
||||
|
||||
@@ -145,8 +145,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
|
||||
force=force, last_mod_time=last_mod_time, timeout=timeout, validate_certs=validate_certs,
|
||||
url_username=url_username, url_password=url_password, http_agent=http_agent,
|
||||
force_basic_auth=force_basic_auth)
|
||||
except HTTPError:
|
||||
err = get_exception()
|
||||
except HTTPError as err:
|
||||
r = err.fp
|
||||
|
||||
try:
|
||||
|
||||
@@ -52,7 +52,7 @@ except ImportError:
|
||||
# which is essentially a cut/paste from an earlier (2.6) version of python's
|
||||
# ast.py
|
||||
from compiler import ast, parse
|
||||
from ansible.module_utils.six import binary_type, string_types, text_type
|
||||
from ansible.module_utils.six import binary_type, integer_types, string_types, text_type
|
||||
|
||||
def literal_eval(node_or_string):
|
||||
"""
|
||||
@@ -68,8 +68,7 @@ except ImportError:
|
||||
node_or_string = node_or_string.node
|
||||
|
||||
def _convert(node):
|
||||
# Okay to use long here because this is only for python 2.4 and 2.5
|
||||
if isinstance(node, ast.Const) and isinstance(node.value, (text_type, binary_type, int, float, long, complex)):
|
||||
if isinstance(node, ast.Const) and isinstance(node.value, (text_type, binary_type, float, complex) + integer_types):
|
||||
return node.value
|
||||
elif isinstance(node, ast.Tuple):
|
||||
return tuple(map(_convert, node.nodes))
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils.six import iteritems
|
||||
import atexit
|
||||
import os
|
||||
import ssl
|
||||
@@ -33,6 +31,9 @@ try:
|
||||
except ImportError:
|
||||
HAS_PYVMOMI = False
|
||||
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
from ansible.module_utils.six import integer_types, iteritems, string_types
|
||||
|
||||
|
||||
class TaskError(Exception):
|
||||
pass
|
||||
@@ -595,17 +596,7 @@ def serialize_spec(clonespec):
|
||||
data[x] = []
|
||||
for xe in xo:
|
||||
data[x].append(serialize_spec(xe))
|
||||
elif issubclass(xt, str):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, unicode):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, int):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, float):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, long):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, bool):
|
||||
elif issubclass(xt, string_types + integer_types + (float, bool)):
|
||||
data[x] = xo
|
||||
elif issubclass(xt, dict):
|
||||
data[x] = {}
|
||||
|
||||
Reference in New Issue
Block a user