Fix rabbitmq modules for python3 import

Also get rid of unnecessary capture of exception into a variable for
python-2.4 compat.
This commit is contained in:
Toshio Kuratomi 2017-08-07 18:52:33 -07:00
parent 441376c754
commit 8894c57753
3 changed files with 18 additions and 16 deletions

View file

@ -105,14 +105,15 @@ EXAMPLES = '''
'''
import json
try:
import requests
HAS_REQUESTS = True
except ImportError as e:
except ImportError:
HAS_REQUESTS = False
import urllib
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six.moves.urllib import parse as urllib_parse
def main():
@ -137,8 +138,8 @@ def main():
url = "http://%s:%s/api/exchanges/%s/%s" % (
module.params['login_host'],
module.params['login_port'],
urllib.quote(module.params['vhost'],''),
urllib.quote(module.params['name'],'')
urllib_parse.quote(module.params['vhost'],''),
urllib_parse.quote(module.params['name'],'')
)
if not HAS_REQUESTS: