Make postgresql module in extras compile on py3

This commit is contained in:
Michael Scherer 2016-10-16 16:57:57 +02:00 committed by Matt Clay
parent 6963cd8ae7
commit 95929fb79f
3 changed files with 10 additions and 6 deletions

View file

@ -159,7 +159,8 @@ def main():
.ISOLATION_LEVEL_AUTOCOMMIT)
cursor = db_connection.cursor(
cursor_factory=psycopg2.extras.DictCursor)
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="unable to connect to database: %s" % e)
try:
@ -174,14 +175,17 @@ def main():
elif state == "present":
changed = ext_create(cursor, ext)
except NotSupportedError, e:
except NotSupportedError:
e = get_exception()
module.fail_json(msg=str(e))
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="Database query failed: %s" % e)
module.exit_json(changed=changed, db=db, ext=ext)
# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.pycompat24 import get_exception
main()