Skip to content

Commit

Permalink
Make postgresql module in extras compile on py3
Browse files Browse the repository at this point in the history
  • Loading branch information
mscherer authored and mattclay committed Dec 8, 2016
1 parent 6963cd8 commit 95929fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions lib/ansible/modules/extras/database/postgresql/postgresql_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()

Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def main():
try:
db_connection = psycopg2.connect(**kw)
cursor = db_connection.cursor()
except Exception, e:
except Exception:
e = get_exception()
module.fail_json(msg="unable to connect to database: %s" % e)
changed = False
lang_dropped = False
Expand Down Expand Up @@ -267,4 +268,5 @@ def main():

# import module snippets
from ansible.module_utils.basic import *
from ansible.module_utils.pycompat24 import get_exception
main()
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@
/clustering/consul_kv.py
/clustering/consul_session.py
/database/mysql/mysql_replication.py
/database/postgresql/postgresql_ext.py
/database/postgresql/postgresql_lang.py
/database/vertica/vertica_configuration.py
/database/vertica/vertica_facts.py
/database/vertica/vertica_role.py
Expand Down

0 comments on commit 95929fb

Please sign in to comment.