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

@ -120,14 +120,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():
@ -155,7 +156,7 @@ def main():
url = "http://%s:%s/api/queues/%s/%s" % (
module.params['login_host'],
module.params['login_port'],
urllib.quote(module.params['vhost'],''),
urllib_parse.quote(module.params['vhost'],''),
module.params['name']
)