Fixed import of urlencode and pathname2url from urllib for python3 (#24424)

This commit is contained in:
Michael 2017-05-19 17:22:16 +00:00 committed by Matt Martz
commit b65ebf3519
26 changed files with 66 additions and 69 deletions

View file

@ -103,15 +103,17 @@ EXAMPLES = '''
# HipChat module specific support methods.
#
import urllib
try:
import json
except ImportError:
import simplejson as json
# import module snippets
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.pycompat24 import get_exception
from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.six.moves.urllib.request import pathname2url
from ansible.module_utils.urls import fetch_url
DEFAULT_URI = "https://api.hipchat.com/v1"
@ -135,7 +137,7 @@ def send_msg_v1(module, token, room, msg_from, msg, msg_format='text',
params['notify'] = int(notify)
url = api + MSG_URI_V1 + "?auth_token=%s" % (token)
data = urllib.urlencode(params)
data = urlencode(params)
if module.check_mode:
# In check mode, exit before actually sending the message
@ -162,7 +164,7 @@ def send_msg_v2(module, token, room, msg_from, msg, msg_format='text',
POST_URL = api + NOTIFY_URI_V2
url = POST_URL.replace('{id_or_name}', urllib.pathname2url(room))
url = POST_URL.replace('{id_or_name}', pathname2url(room))
data = json.dumps(body)
if module.check_mode: