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'
|
||||
|
||||
if hasattr(self, 'url'):
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
from urllib.parse import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
o = urlparse(self.url)
|
||||
if o.hostname:
|
||||
host = o.hostname
|
||||
|
|
|
@ -56,12 +56,8 @@ import argparse
|
|||
import six
|
||||
import httplib2 as http
|
||||
from time import time
|
||||
from six.moves import configparser
|
||||
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
from urllib.parse import urlparse
|
||||
from ansible.module_utils.six.moves import configparser
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
import json
|
||||
|
|
|
@ -39,7 +39,7 @@ import re
|
|||
import sys
|
||||
import argparse
|
||||
import os
|
||||
from urlparse import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
from time import time
|
||||
try:
|
||||
import json
|
||||
|
|
|
@ -30,10 +30,7 @@ import os
|
|||
import hmac
|
||||
import re
|
||||
|
||||
try:
|
||||
import urlparse
|
||||
except ImportError:
|
||||
import urllib.parse as urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
from hashlib import sha1
|
||||
|
@ -75,7 +72,7 @@ def get_fqdn_and_port(repo_url):
|
|||
fqdn = repo_url.split("/")[0]
|
||||
elif "://" in repo_url:
|
||||
# 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
|
||||
# ensure we actually have a parts[1] before continuing.
|
||||
if parts[1] != '':
|
||||
|
|
|
@ -166,7 +166,7 @@ firewall_policy:
|
|||
__version__ = '${version}'
|
||||
|
||||
import os
|
||||
import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
from time import sleep
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
|
@ -288,7 +288,7 @@ class ClcFirewallPolicy:
|
|||
:return: policy_id: firewall policy id from creation call
|
||||
"""
|
||||
url = response.get('links')[0]['href']
|
||||
path = urlparse.urlparse(url).path
|
||||
path = urlparse(url).path
|
||||
path_list = os.path.split(path)
|
||||
policy_id = path_list[-1]
|
||||
return policy_id
|
||||
|
|
|
@ -516,11 +516,7 @@ EXAMPLES = '''
|
|||
import json
|
||||
import os
|
||||
import shlex
|
||||
try:
|
||||
from urlparse import urlparse
|
||||
except ImportError:
|
||||
# python3
|
||||
from urllib.parse import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
import docker.client
|
||||
|
|
|
@ -236,11 +236,7 @@ import ssl
|
|||
from httplib import HTTPSConnection
|
||||
from httplib import IncompleteRead
|
||||
|
||||
try:
|
||||
from urllib.parse import urlparse
|
||||
except ImportError:
|
||||
from urlparse import urlparse
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
import ovirtsdk4.types as otypes
|
||||
|
|
|
@ -22,7 +22,7 @@ __metaclass__ = type
|
|||
import os
|
||||
import time
|
||||
import glob
|
||||
import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlsplit
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.plugins.action.ce import ActionModule as _ActionModule
|
||||
|
@ -72,7 +72,7 @@ class ActionModule(_ActionModule):
|
|||
|
||||
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
|
||||
else:
|
||||
source = self._loader.path_dwim_relative(working_path, 'templates', src)
|
||||
|
|
|
@ -61,7 +61,7 @@ RETURN = """
|
|||
|
||||
import os
|
||||
import sys
|
||||
from urlparse import urlparse
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse
|
||||
from ansible.errors import AnsibleError
|
||||
from ansible.plugins.lookup import LookupBase
|
||||
|
||||
|
|
Loading…
Reference in a new issue