mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
Fix urlparse import for Python3 (#31240)
* Fix urlparse import for Python3 in * contrib/inventory/consul_io.py * contrib/inventory/rudder.py * contrib/inventory/windows_azure.py * lib/ansible/module_utils/known_hosts.py * lib/ansible/modules/cloud/centurylink/clc_firewall_policy.py * lib/ansible/modules/cloud/docker/_docker.py * lib/ansible/modules/cloud/ovirt/ovirt_disk.py * lib/ansible/plugins/action/ce_template.py
This commit is contained in:
parent
2b2e3e688f
commit
aade5234a9
9 changed files with 13 additions and 31 deletions
|
@ -473,10 +473,7 @@ class ConsulConfig(dict):
|
||||||
scheme = 'http'
|
scheme = 'http'
|
||||||
|
|
||||||
if hasattr(self, 'url'):
|
if hasattr(self, 'url'):
|
||||||
try:
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
from urlparse import urlparse
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
o = urlparse(self.url)
|
o = urlparse(self.url)
|
||||||
if o.hostname:
|
if o.hostname:
|
||||||
host = o.hostname
|
host = o.hostname
|
||||||
|
|
|
@ -56,12 +56,8 @@ import argparse
|
||||||
import six
|
import six
|
||||||
import httplib2 as http
|
import httplib2 as http
|
||||||
from time import time
|
from time import time
|
||||||
from six.moves import configparser
|
from ansible.module_utils.six.moves import configparser
|
||||||
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
try:
|
|
||||||
from urlparse import urlparse
|
|
||||||
except ImportError:
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -39,7 +39,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
from urlparse import urlparse
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
from time import time
|
from time import time
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
|
|
@ -30,10 +30,7 @@ import os
|
||||||
import hmac
|
import hmac
|
||||||
import re
|
import re
|
||||||
|
|
||||||
try:
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
import urlparse
|
|
||||||
except ImportError:
|
|
||||||
import urllib.parse as urlparse
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
@ -75,7 +72,7 @@ def get_fqdn_and_port(repo_url):
|
||||||
fqdn = repo_url.split("/")[0]
|
fqdn = repo_url.split("/")[0]
|
||||||
elif "://" in repo_url:
|
elif "://" in repo_url:
|
||||||
# this should be something we can parse with urlparse
|
# this should be something we can parse with urlparse
|
||||||
parts = urlparse.urlparse(repo_url)
|
parts = urlparse(repo_url)
|
||||||
# parts[1] will be empty on python2.4 on ssh:// or git:// urls, so
|
# parts[1] will be empty on python2.4 on ssh:// or git:// urls, so
|
||||||
# ensure we actually have a parts[1] before continuing.
|
# ensure we actually have a parts[1] before continuing.
|
||||||
if parts[1] != '':
|
if parts[1] != '':
|
||||||
|
|
|
@ -166,7 +166,7 @@ firewall_policy:
|
||||||
__version__ = '${version}'
|
__version__ = '${version}'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
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 distutils.version import LooseVersion
|
||||||
|
|
||||||
|
@ -288,7 +288,7 @@ class ClcFirewallPolicy:
|
||||||
:return: policy_id: firewall policy id from creation call
|
:return: policy_id: firewall policy id from creation call
|
||||||
"""
|
"""
|
||||||
url = response.get('links')[0]['href']
|
url = response.get('links')[0]['href']
|
||||||
path = urlparse.urlparse(url).path
|
path = urlparse(url).path
|
||||||
path_list = os.path.split(path)
|
path_list = os.path.split(path)
|
||||||
policy_id = path_list[-1]
|
policy_id = path_list[-1]
|
||||||
return policy_id
|
return policy_id
|
||||||
|
|
|
@ -516,11 +516,7 @@ EXAMPLES = '''
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
try:
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
from urlparse import urlparse
|
|
||||||
except ImportError:
|
|
||||||
# python3
|
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import docker.client
|
import docker.client
|
||||||
|
|
|
@ -236,11 +236,7 @@ import ssl
|
||||||
from httplib import HTTPSConnection
|
from httplib import HTTPSConnection
|
||||||
from httplib import IncompleteRead
|
from httplib import IncompleteRead
|
||||||
|
|
||||||
try:
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
from urllib.parse import urlparse
|
|
||||||
except ImportError:
|
|
||||||
from urlparse import urlparse
|
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import ovirtsdk4.types as otypes
|
import ovirtsdk4.types as otypes
|
||||||
|
|
|
@ -22,7 +22,7 @@ __metaclass__ = type
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import glob
|
import glob
|
||||||
import urlparse
|
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||||
|
|
||||||
from ansible.module_utils._text import to_text
|
from ansible.module_utils._text import to_text
|
||||||
from ansible.plugins.action.ce import ActionModule as _ActionModule
|
from ansible.plugins.action.ce import ActionModule as _ActionModule
|
||||||
|
@ -72,7 +72,7 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
working_path = self._get_working_path()
|
working_path = self._get_working_path()
|
||||||
|
|
||||||
if os.path.isabs(src) or urlparse.urlsplit(src).scheme:
|
if os.path.isabs(src) or urlsplit(src).scheme:
|
||||||
source = src
|
source = src
|
||||||
else:
|
else:
|
||||||
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
||||||
|
|
|
@ -61,7 +61,7 @@ RETURN = """
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from urlparse import urlparse
|
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||||
from ansible.errors import AnsibleError
|
from ansible.errors import AnsibleError
|
||||||
from ansible.plugins.lookup import LookupBase
|
from ansible.plugins.lookup import LookupBase
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue