From 715b88a8a53bf51eb20886c0cb94e9fd3bf61f2c Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sat, 15 Oct 2016 17:01:46 +0200 Subject: [PATCH] Make redis run on python 3 --- .../modules/extras/database/misc/redis.py | 16 +++++++++++----- .../test/utils/shippable/sanity-skip-python3.txt | 1 - 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lib/ansible/modules/extras/database/misc/redis.py b/lib/ansible/modules/extras/database/misc/redis.py index b5bc960d83d..00c3478d117 100644 --- a/lib/ansible/modules/extras/database/misc/redis.py +++ b/lib/ansible/modules/extras/database/misc/redis.py @@ -210,7 +210,8 @@ def main(): password=login_password) try: r.ping() - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="unable to connect to database: %s" % e) #Check if we are already in the mode that we want @@ -269,7 +270,8 @@ def main(): db=db) try: r.ping() - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="unable to connect to database: %s" % e) # Do the stuff @@ -296,13 +298,15 @@ def main(): try: r.ping() - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="unable to connect to database: %s" % e) try: old_value = r.config_get(name)[name] - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="unable to read config: %s" % e) changed = old_value != value @@ -311,7 +315,8 @@ def main(): else: try: r.config_set(name, value) - except Exception, e: + except Exception: + e = get_exception() module.fail_json(msg="unable to write config: %s" % e) module.exit_json(changed=changed, name=name, value=value) else: @@ -319,4 +324,5 @@ def main(): # import module snippets from ansible.module_utils.basic import * +from ansible.module_utils.pycompat24 import get_exception main() diff --git a/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt b/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt index c255551af97..4c0ff360429 100644 --- a/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt +++ b/lib/ansible/modules/extras/test/utils/shippable/sanity-skip-python3.txt @@ -48,7 +48,6 @@ /clustering/consul_session.py /database/misc/mongodb_parameter.py /database/misc/mongodb_user.py -/database/misc/redis.py /database/mysql/mysql_replication.py /database/postgresql/postgresql_ext.py /database/postgresql/postgresql_lang.py