Final round of moving modules to new import error msg (#51852)

* Final round of moving modules to new import error msg

* readd URL to jenkins install guide

* fix unit tests
This commit is contained in:
Jordan Borean 2019-02-08 10:07:01 +10:00 committed by GitHub
parent ffbc9d99de
commit a39c4ad464
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 292 additions and 150 deletions

View file

@ -137,13 +137,15 @@ import ssl
import fnmatch
import traceback
JENKINS_IMP_ERR = None
try:
import jenkins
HAS_JENKINS = True
except ImportError:
JENKINS_IMP_ERR = traceback.format_exc()
HAS_JENKINS = 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
@ -171,8 +173,9 @@ def get_jenkins_connection(module):
def test_dependencies(module):
if not HAS_JENKINS:
module.fail_json(
msg="python-jenkins required for this module. "
"see http://python-jenkins.readthedocs.io/en/latest/install.html")
msg=missing_required_lib("python-jenkins",
url="https://python-jenkins.readthedocs.io/en/latest/install.html"),
exception=JENKINS_IMP_ERR)
def get_jobs(module):