mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
start getting modules to use shared import error code (#51787)
This commit is contained in:
parent
0924a8cf67
commit
0f0d33a954
46 changed files with 230 additions and 108 deletions
|
@ -115,16 +115,18 @@ import pipes
|
|||
import subprocess
|
||||
import traceback
|
||||
|
||||
PSYCOPG2_IMP_ERR = None
|
||||
try:
|
||||
import psycopg2
|
||||
import psycopg2.extras
|
||||
except ImportError:
|
||||
PSYCOPG2_IMP_ERR = traceback.format_exc()
|
||||
HAS_PSYCOPG2 = False
|
||||
else:
|
||||
HAS_PSYCOPG2 = True
|
||||
|
||||
import ansible.module_utils.postgres as pgutils
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils.database import SQLParseError, pg_quote_identifier
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils._text import to_native
|
||||
|
@ -384,7 +386,7 @@ def main():
|
|||
)
|
||||
|
||||
if not HAS_PSYCOPG2:
|
||||
module.fail_json(msg="the python psycopg2 module is required")
|
||||
module.fail_json(msg=missing_required_lib('psycopg2'), exception=PSYCOPG2_IMP_ERR)
|
||||
|
||||
db = module.params["db"]
|
||||
owner = module.params["owner"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue