1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Prepare for distutils.version being removed in Python 3.12 (#3936)

* Prepare for distutils.version being removed in Python 2.12.

* Fix copy'n'paste error.

* Re-add Loose prefix.

* Fix Python version typos.

* Improve formulation.

* Move message into own line.

* Fix casing, now that the object is no longer called Version.
This commit is contained in:
Felix Fontein 2021-12-24 18:34:48 +01:00 committed by GitHub
parent f34c454412
commit a2f72be6c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 106 additions and 63 deletions

View file

@ -0,0 +1,2 @@
bugfixes:
- "Various modules and plugins - use vendored version of ``distutils.version`` included in ansible-core 2.12 if available. This avoids breakage when ``distutils`` is removed from the standard library of Python 3.12. Note that ansible-core 2.11, ansible-base 2.10 and Ansible 2.9 are right now not compatible with Python 3.12, hence this fix does not target these ansible-core/-base/2.9 versions (https://github.com/ansible-collections/community.general/pull/3936)."

View file

@ -5,7 +5,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from distutils.version import LooseVersion from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
def version_sort(value, reverse=False): def version_sort(value, reverse=False):

View file

@ -68,7 +68,6 @@ user: ansible-tester
password: secure password: secure
''' '''
from distutils.version import LooseVersion
import socket import socket
from ansible.errors import AnsibleError from ansible.errors import AnsibleError

View file

@ -119,12 +119,13 @@ compose:
import re import re
from ansible.module_utils.common._collections_compat import MutableMapping from ansible.module_utils.common._collections_compat import MutableMapping
from distutils.version import LooseVersion
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible.module_utils.six.moves.urllib.parse import urlencode from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
# 3rd party imports # 3rd party imports
try: try:
import requests import requests

View file

@ -79,11 +79,11 @@ simple_config_file:
import json import json
import ssl import ssl
from distutils.version import LooseVersion
from ansible.errors import AnsibleError from ansible.errors import AnsibleError
from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
# 3rd party imports # 3rd party imports
try: try:
HAS_WEBSOCKET = True HAS_WEBSOCKET = True

View file

@ -7,11 +7,11 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from distutils.version import StrictVersion
from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.basic import missing_required_lib
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try: try:
from urllib import quote_plus # Python 2.X from urllib import quote_plus # Python 2.X
from urlparse import urljoin from urlparse import urljoin
@ -79,7 +79,7 @@ def gitlab_authentication(module):
# python-gitlab library remove support for username/password authentication since 1.13.0 # python-gitlab library remove support for username/password authentication since 1.13.0
# Changelog : https://github.com/python-gitlab/python-gitlab/releases/tag/v1.13.0 # Changelog : https://github.com/python-gitlab/python-gitlab/releases/tag/v1.13.0
# This condition allow to still support older version of the python-gitlab library # This condition allow to still support older version of the python-gitlab library
if StrictVersion(gitlab.__version__) < StrictVersion("1.13.0"): if LooseVersion(gitlab.__version__) < LooseVersion("1.13.0"):
gitlab_instance = gitlab.Gitlab(url=gitlab_url, ssl_verify=validate_certs, email=gitlab_user, password=gitlab_password, gitlab_instance = gitlab.Gitlab(url=gitlab_url, ssl_verify=validate_certs, email=gitlab_user, password=gitlab_password,
private_token=gitlab_token, api_version=4) private_token=gitlab_token, api_version=4)
else: else:

View file

@ -9,7 +9,8 @@ __metaclass__ = type
import traceback import traceback
from ansible.module_utils.basic import missing_required_lib from ansible.module_utils.basic import missing_required_lib
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright: (c) 2021, Felix Fontein <felix@fontein.de>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""Provide version object to compare version numbers."""
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible.module_utils.six import raise_from
try:
from ansible.module_utils.compat.version import LooseVersion
except ImportError:
try:
from distutils.version import LooseVersion
except ImportError as exc:
msg = 'To use this plugin or module with ansible-core < 2.11, you need to use Python < 3.12 with distutils.version present'
raise_from(ImportError(msg), exc)

View file

@ -120,7 +120,7 @@ __version__ = '${version}'
import os import os
import traceback import traceback
from distutils.version import LooseVersion from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -161,7 +161,8 @@ __version__ = '${version}'
import json import json
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -89,7 +89,8 @@ __version__ = '${version}'
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -132,8 +133,7 @@ class ClcBlueprintPackage:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -162,7 +162,8 @@ import os
import traceback import traceback
from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.module_utils.six.moves.urllib.parse import urlparse
from time import sleep from time import sleep
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -203,8 +204,7 @@ class ClcFirewallPolicy:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -207,7 +207,8 @@ __version__ = '${version}'
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -210,7 +210,8 @@ import json
import os import os
import traceback import traceback
from time import sleep from time import sleep
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -255,8 +256,7 @@ class ClcLoadBalancer:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -311,7 +311,8 @@ __version__ = '${version}'
import json import json
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -355,8 +356,7 @@ class ClcModifyServer:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -117,7 +117,8 @@ __version__ = '${version}'
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -433,7 +433,8 @@ import json
import os import os
import time import time
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -478,8 +479,7 @@ class ClcServer:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -101,7 +101,8 @@ __version__ = '${version}'
import os import os
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:
@ -145,8 +146,7 @@ class ClcSnapshot:
self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR) self.module.fail_json(msg=missing_required_lib('clc-sdk'), exception=CLC_IMP_ERR)
if not REQUESTS_FOUND: if not REQUESTS_FOUND:
self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR) self.module.fail_json(msg=missing_required_lib('requests'), exception=REQUESTS_IMP_ERR)
if requests.__version__ and LooseVersion( if requests.__version__ and LooseVersion(requests.__version__) < LooseVersion('2.5.0'):
requests.__version__) < LooseVersion('2.5.0'):
self.module.fail_json( self.module.fail_json(
msg='requests library version should be >= 2.5.0') msg='requests library version should be >= 2.5.0')

View file

@ -348,7 +348,8 @@ EXAMPLES = r'''
import time import time
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try: try:
from proxmoxer import ProxmoxAPI from proxmoxer import ProxmoxAPI

View file

@ -725,9 +725,10 @@ msg:
import re import re
import time import time
import traceback import traceback
from distutils.version import LooseVersion
from ansible.module_utils.six.moves.urllib.parse import quote from ansible.module_utils.six.moves.urllib.parse import quote
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try: try:
from proxmoxer import ProxmoxAPI from proxmoxer import ProxmoxAPI
HAS_PROXMOXER = True HAS_PROXMOXER = True

View file

@ -230,11 +230,12 @@ command:
import os import os
import json import json
import tempfile import tempfile
from distutils.version import LooseVersion
from ansible.module_utils.six.moves import shlex_quote from ansible.module_utils.six.moves import shlex_quote
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
module = None module = None

View file

@ -97,7 +97,7 @@ EXAMPLES = '''
register: my_volume register: my_volume
''' '''
from distutils.version import LooseVersion from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try: try:
import pyrax import pyrax

View file

@ -117,9 +117,10 @@ state:
''' '''
import os import os
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
PACKAGE_STATE_MAP = dict( PACKAGE_STATE_MAP = dict(
present="--install", present="--install",

View file

@ -356,9 +356,10 @@ import os
import re import re
import traceback import traceback
from distutils.version import LooseVersion
from io import BytesIO from io import BytesIO
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
LXML_IMP_ERR = None LXML_IMP_ERR = None
try: try:
from lxml import etree, objectify from lxml import etree, objectify

View file

@ -74,11 +74,12 @@ subca:
type: dict type: dict
''' '''
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.ipa import IPAClient, ipa_argument_spec from ansible_collections.community.general.plugins.module_utils.ipa import IPAClient, ipa_argument_spec
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
class SubCAIPAClient(IPAClient): class SubCAIPAClient(IPAClient):
def __init__(self, module, host, port, protocol): def __init__(self, module, host, port, protocol):

View file

@ -143,7 +143,8 @@ annotation:
import json import json
import time import time
import traceback import traceback
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REQUESTS_IMP_ERR = None REQUESTS_IMP_ERR = None
try: try:

View file

@ -148,9 +148,10 @@ EXAMPLES = '''
RETURN = r"""# """ RETURN = r"""# """
import traceback import traceback
from distutils.version import LooseVersion
import re import re
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
class DNSimpleV1(): class DNSimpleV1():
"""class which uses dnsimple-python < 2""" """class which uses dnsimple-python < 2"""

View file

@ -124,7 +124,8 @@ import os
import ssl import ssl
import traceback import traceback
import platform import platform
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
HAS_PAHOMQTT = True HAS_PAHOMQTT = True
PAHOMQTT_IMP_ERR = None PAHOMQTT_IMP_ERR = None
@ -207,7 +208,7 @@ def main():
if tls_version: if tls_version:
tls_version = tls_map.get(tls_version, ssl.PROTOCOL_SSLv23) tls_version = tls_map.get(tls_version, ssl.PROTOCOL_SSLv23)
else: else:
if LooseVersion(platform.python_version()) <= "3.5.2": if LooseVersion(platform.python_version()) <= LooseVersion("3.5.2"):
# Specifying `None` on later versions of python seems sufficient to # Specifying `None` on later versions of python seems sufficient to
# instruct python to autonegotiate the SSL/TLS connection. On versions # instruct python to autonegotiate the SSL/TLS connection. On versions
# 3.5.2 and lower though we need to specify the version. # 3.5.2 and lower though we need to specify the version.

View file

@ -124,7 +124,7 @@ EXAMPLES = r'''
import os import os
import traceback import traceback
from distutils.version import LooseVersion from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
SENDGRID_IMP_ERR = None SENDGRID_IMP_ERR = None
try: try:

View file

@ -152,11 +152,11 @@ stdout:
sample: "org.gnome.Calendar/x86_64/stable\tcurrent\norg.gnome.gitg/x86_64/stable\tcurrent\n" sample: "org.gnome.Calendar/x86_64/stable\tcurrent\norg.gnome.gitg/x86_64/stable\tcurrent\n"
''' '''
from distutils.version import StrictVersion
from ansible.module_utils.six.moves.urllib.parse import urlparse from ansible.module_utils.six.moves.urllib.parse import urlparse
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
OUTDATED_FLATPAK_VERSION_ERROR_MESSAGE = "Unknown option --columns=application" OUTDATED_FLATPAK_VERSION_ERROR_MESSAGE = "Unknown option --columns=application"
@ -172,7 +172,7 @@ def install_flat(module, binary, remote, names, method, no_dependencies):
id_names.append(name) id_names.append(name)
base_command = [binary, "install", "--{0}".format(method)] base_command = [binary, "install", "--{0}".format(method)]
flatpak_version = _flatpak_version(module, binary) flatpak_version = _flatpak_version(module, binary)
if StrictVersion(flatpak_version) < StrictVersion('1.1.3'): if LooseVersion(flatpak_version) < LooseVersion('1.1.3'):
base_command += ["-y"] base_command += ["-y"]
else: else:
base_command += ["--noninteractive"] base_command += ["--noninteractive"]
@ -196,7 +196,7 @@ def uninstall_flat(module, binary, names, method):
] ]
command = [binary, "uninstall"] command = [binary, "uninstall"]
flatpak_version = _flatpak_version(module, binary) flatpak_version = _flatpak_version(module, binary)
if StrictVersion(flatpak_version) < StrictVersion('1.1.3'): if LooseVersion(flatpak_version) < LooseVersion('1.1.3'):
command += ["-y"] command += ["-y"]
else: else:
command += ["--noninteractive"] command += ["--noninteractive"]

View file

@ -140,7 +140,8 @@ EXAMPLES = '''
import os import os
import re import re
import tempfile import tempfile
from distutils import version
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
from ansible.module_utils.common.text.converters import to_bytes from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
@ -493,7 +494,7 @@ class HomebrewCask(object):
def _brew_cask_command_is_deprecated(self): def _brew_cask_command_is_deprecated(self):
# The `brew cask` replacements were fully available in 2.6.0 (https://brew.sh/2020/12/01/homebrew-2.6.0/) # The `brew cask` replacements were fully available in 2.6.0 (https://brew.sh/2020/12/01/homebrew-2.6.0/)
return version.LooseVersion(self._get_brew_version()) >= version.LooseVersion('2.6.0') return LooseVersion(self._get_brew_version()) >= LooseVersion('2.6.0')
# /checks ------------------------------------------------------ }}} # /checks ------------------------------------------------------ }}}
# commands ----------------------------------------------------- {{{ # commands ----------------------------------------------------- {{{

View file

@ -97,9 +97,10 @@ RETURN = r''' # '''
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from distutils.version import StrictVersion
import os import os
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
class Mas(object): class Mas(object):
@ -145,7 +146,7 @@ class Mas(object):
# Is the version recent enough? # Is the version recent enough?
rc, out, err = self.run(['version']) rc, out, err = self.run(['version'])
if rc != 0 or not out.strip() or StrictVersion(out.strip()) < StrictVersion('1.5.0'): if rc != 0 or not out.strip() or LooseVersion(out.strip()) < LooseVersion('1.5.0'):
self.module.fail_json(msg='`mas` tool in version 1.5.0+ needed, got ' + out.strip()) self.module.fail_json(msg='`mas` tool in version 1.5.0+ needed, got ' + out.strip())
def check_signin(self): def check_signin(self):

View file

@ -135,10 +135,10 @@ import re
import shlex import shlex
import sqlite3 import sqlite3
from distutils.version import StrictVersion
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
# Function used for executing commands. # Function used for executing commands.
def execute_command(cmd, module): def execute_command(cmd, module):
@ -435,7 +435,7 @@ def parse_package_name(names, pkg_spec, module):
if pkg_spec[name]['branch']: if pkg_spec[name]['branch']:
branch_release = "6.0" branch_release = "6.0"
if StrictVersion(platform.release()) < StrictVersion(branch_release): if LooseVersion(platform.release()) < LooseVersion(branch_release):
module.fail_json(msg="package name using 'branch' syntax requires at least OpenBSD %s: %s" % (branch_release, name)) module.fail_json(msg="package name using 'branch' syntax requires at least OpenBSD %s: %s" % (branch_release, name))
# Sanity check that there are no trailing dashes in flavor. # Sanity check that there are no trailing dashes in flavor.

View file

@ -133,8 +133,6 @@ except ImportError:
XML_IMP_ERR = traceback.format_exc() XML_IMP_ERR = traceback.format_exc()
HAS_XML = False HAS_XML = False
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.urls import fetch_url from ansible.module_utils.urls import fetch_url
@ -142,6 +140,8 @@ from ansible.module_utils.common.text.converters import to_text
from ansible.module_utils.six.moves import configparser, StringIO from ansible.module_utils.six.moves import configparser, StringIO
from io import open from io import open
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
REPO_OPTS = ['alias', 'name', 'priority', 'enabled', 'autorefresh', 'gpgcheck'] REPO_OPTS = ['alias', 'name', 'priority', 'enabled', 'autorefresh', 'gpgcheck']

View file

@ -73,7 +73,8 @@ import traceback
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.api import basic_auth_argument_spec from ansible.module_utils.api import basic_auth_argument_spec
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
GITLAB_IMP_ERR = None GITLAB_IMP_ERR = None
try: try:

View file

@ -73,7 +73,8 @@ import traceback
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.api import basic_auth_argument_spec from ansible.module_utils.api import basic_auth_argument_spec
from distutils.version import LooseVersion
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
GITLAB_IMP_ERR = None GITLAB_IMP_ERR = None
try: try:

View file

@ -158,11 +158,12 @@ diversion:
import re import re
import os import os
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_bytes, to_native from ansible.module_utils.common.text.converters import to_bytes, to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
def diversion_state(module, command, path): def diversion_state(module, command, path):
diversion = dict(path=path, state='absent', divert=None, holder=None) diversion = dict(path=path, state='absent', divert=None, holder=None)

View file

@ -115,7 +115,6 @@ EXAMPLES = '''
fstype: vfat fstype: vfat
''' '''
from distutils.version import LooseVersion
import os import os
import platform import platform
import re import re
@ -124,6 +123,8 @@ import stat
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
class Device(object): class Device(object):
def __init__(self, module, path): def __init__(self, module, path):

View file

@ -56,13 +56,14 @@ pids:
import abc import abc
import re import re
from distutils.version import LooseVersion
from os.path import basename from os.path import basename
from ansible.module_utils import six from ansible.module_utils import six
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
try: try:
import psutil import psutil

View file

@ -122,7 +122,7 @@ import operator
HAS_DISTUTILS = False HAS_DISTUTILS = False
try: try:
import pkg_resources import pkg_resources
from distutils.version import LooseVersion from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
HAS_DISTUTILS = True HAS_DISTUTILS = True
except ImportError: except ImportError:
pass pass

View file

@ -95,10 +95,11 @@ EXAMPLES = """
import os import os
import tempfile import tempfile
import traceback import traceback
from distutils.version import LooseVersion
from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.basic import AnsibleModule, missing_required_lib
from ansible.module_utils.common.text.converters import to_native from ansible.module_utils.common.text.converters import to_native
from ansible_collections.community.general.plugins.module_utils.version import LooseVersion
PASSLIB_IMP_ERR = None PASSLIB_IMP_ERR = None
try: try:
from passlib.apache import HtpasswdFile, htpasswd_context from passlib.apache import HtpasswdFile, htpasswd_context