mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
Use common functions for handling import errors (#51851)
* Use common functions for handling import errors * use refactored version of gitlab modules
This commit is contained in:
@@ -66,14 +66,17 @@ EXAMPLES = '''
|
||||
when: r.issue_status == 'open'
|
||||
'''
|
||||
|
||||
import traceback
|
||||
|
||||
GITHUB_IMP_ERR = None
|
||||
try:
|
||||
import github3
|
||||
HAS_GITHUB_PACKAGE = True
|
||||
except ImportError:
|
||||
GITHUB_IMP_ERR = traceback.format_exc()
|
||||
HAS_GITHUB_PACKAGE = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.basic import AnsibleModule, missing_required_lib
|
||||
|
||||
|
||||
def main():
|
||||
@@ -88,8 +91,8 @@ def main():
|
||||
)
|
||||
|
||||
if not HAS_GITHUB_PACKAGE:
|
||||
module.fail_json(msg="Missing required github3 module. (check docs or "
|
||||
"install with: pip install github3.py==1.0.0a4)")
|
||||
module.fail_json(msg=missing_required_lib('github3.py >= 1.0.0a4'),
|
||||
exception=GITHUB_IMP_ERR)
|
||||
|
||||
organization = module.params['organization']
|
||||
repo = module.params['repo']
|
||||
|
||||
Reference in New Issue
Block a user