mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 12:21:26 -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
|
@ -98,13 +98,15 @@ import datetime
|
|||
import os
|
||||
import traceback
|
||||
|
||||
PEXPECT_IMP_ERR = None
|
||||
try:
|
||||
import pexpect
|
||||
HAS_PEXPECT = True
|
||||
except ImportError:
|
||||
PEXPECT_IMP_ERR = traceback.format_exc()
|
||||
HAS_PEXPECT = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
from ansible.module_utils._text import to_native, to_text
|
||||
|
||||
|
||||
|
@ -137,7 +139,8 @@ def main():
|
|||
)
|
||||
|
||||
if not HAS_PEXPECT:
|
||||
module.fail_json(msg='The pexpect python module is required')
|
||||
module.fail_json(msg=missing_required_lib("pexpect"),
|
||||
exception=PEXPECT_IMP_ERR)
|
||||
|
||||
chdir = module.params['chdir']
|
||||
args = module.params['command']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue