mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Fixed import of urlencode and pathname2url from urllib for python3 (#24424)
This commit is contained in:
@@ -77,7 +77,7 @@ EXAMPLES = '''
|
||||
revision: '4.2'
|
||||
'''
|
||||
|
||||
import urllib
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
# ===========================================
|
||||
# Module execution.
|
||||
@@ -122,7 +122,7 @@ def main():
|
||||
module.exit_json(changed=True)
|
||||
|
||||
# Send the data to airbrake
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
response, info = fetch_url(module, url, data=data)
|
||||
if info['status'] == 200:
|
||||
module.exit_json(changed=True)
|
||||
|
||||
@@ -82,11 +82,10 @@ EXAMPLES = '''
|
||||
|
||||
RETURN = '''# '''
|
||||
|
||||
import urllib
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
from ansible.module_utils.urls import *
|
||||
|
||||
# ===========================================
|
||||
@@ -131,7 +130,7 @@ def main():
|
||||
module.exit_json(changed=True)
|
||||
|
||||
try:
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
response, info = fetch_url(module, url, data=data)
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
@@ -144,4 +143,3 @@ def main():
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
||||
@@ -530,7 +530,8 @@ import platform
|
||||
import socket
|
||||
import sys
|
||||
import types
|
||||
import urllib
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
@@ -575,8 +576,8 @@ class LogicMonitor(object):
|
||||
and return the response"""
|
||||
self.module.debug("Running LogicMonitor.rpc")
|
||||
|
||||
param_str = urllib.urlencode(params)
|
||||
creds = urllib.urlencode(
|
||||
param_str = urlencode(params)
|
||||
creds = urlencode(
|
||||
{"c": self.company,
|
||||
"u": self.user,
|
||||
"p": self.password})
|
||||
@@ -614,8 +615,8 @@ class LogicMonitor(object):
|
||||
server \"do\" function"""
|
||||
self.module.debug("Running LogicMonitor.do...")
|
||||
|
||||
param_str = urllib.urlencode(params)
|
||||
creds = (urllib.urlencode(
|
||||
param_str = urlencode(params)
|
||||
creds = (urlencode(
|
||||
{"c": self.company,
|
||||
"u": self.user,
|
||||
"p": self.password}))
|
||||
|
||||
@@ -135,7 +135,8 @@ RETURN = '''
|
||||
|
||||
import socket
|
||||
import types
|
||||
import urllib
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
HAS_LIB_JSON = True
|
||||
try:
|
||||
@@ -179,8 +180,8 @@ class LogicMonitor(object):
|
||||
and return the response"""
|
||||
self.module.debug("Running LogicMonitor.rpc")
|
||||
|
||||
param_str = urllib.urlencode(params)
|
||||
creds = urllib.urlencode(
|
||||
param_str = urlencode(params)
|
||||
creds = urlencode(
|
||||
{"c": self.company,
|
||||
"u": self.user,
|
||||
"p": self.password})
|
||||
|
||||
@@ -88,7 +88,7 @@ EXAMPLES = '''
|
||||
revision: '1.0'
|
||||
'''
|
||||
|
||||
import urllib
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
# ===========================================
|
||||
# Module execution.
|
||||
@@ -135,7 +135,7 @@ def main():
|
||||
|
||||
# Send the data to NewRelic
|
||||
url = "https://rpm.newrelic.com/deployments.xml"
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
headers = {
|
||||
'x-api-key': module.params["token"],
|
||||
}
|
||||
|
||||
@@ -82,10 +82,9 @@ EXAMPLES = '''
|
||||
comment: Test Deploy
|
||||
'''
|
||||
|
||||
import urllib
|
||||
|
||||
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.urls import fetch_url
|
||||
|
||||
|
||||
@@ -129,7 +128,7 @@ def main():
|
||||
url = module.params.get('url')
|
||||
|
||||
try:
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
response, info = fetch_url(module, url, data=data)
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
|
||||
@@ -79,9 +79,10 @@ except ImportError:
|
||||
# Let snippet from module_utils/basic.py return a proper error in this case
|
||||
pass
|
||||
|
||||
import urllib
|
||||
import time
|
||||
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlencode
|
||||
|
||||
API_BASE = "http://api.uptimerobot.com/"
|
||||
|
||||
API_ACTIONS = dict(
|
||||
@@ -97,7 +98,7 @@ SUPPORTS_CHECK_MODE = False
|
||||
|
||||
def checkID(module, params):
|
||||
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
full_uri = API_BASE + API_ACTIONS['status'] + data
|
||||
req, info = fetch_url(module, full_uri)
|
||||
result = req.read()
|
||||
@@ -109,7 +110,7 @@ def checkID(module, params):
|
||||
def startMonitor(module, params):
|
||||
|
||||
params['monitorStatus'] = 1
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
||||
req, info = fetch_url(module, full_uri)
|
||||
result = req.read()
|
||||
@@ -121,7 +122,7 @@ def startMonitor(module, params):
|
||||
def pauseMonitor(module, params):
|
||||
|
||||
params['monitorStatus'] = 0
|
||||
data = urllib.urlencode(params)
|
||||
data = urlencode(params)
|
||||
full_uri = API_BASE + API_ACTIONS['editMonitor'] + data
|
||||
req, info = fetch_url(module, full_uri)
|
||||
result = req.read()
|
||||
|
||||
Reference in New Issue
Block a user