start getting modules to use shared import error code (#51787)

This commit is contained in:
Jordan Borean 2019-02-07 03:39:17 +10:00 committed by Sam Doran
parent 0924a8cf67
commit 0f0d33a954
46 changed files with 230 additions and 108 deletions

View file

@ -727,10 +727,13 @@ def jsonify(data, **kwargs):
raise UnicodeError('Invalid unicode encoding encountered')
def missing_required_lib(library):
def missing_required_lib(library, reason=None):
hostname = platform.node()
return "Failed to import the required Python library (%s) on %s's Python %s. Please read module documentation " \
"and install in the appropriate location." % (library, hostname, sys.executable)
msg = "Failed to import the required Python library (%s) on %s's Python %s." % (library, hostname, sys.executable)
if reason:
msg += " This is required %s." % reason
return msg + " Please read module documentation and install in the appropriate location"
class AnsibleFallbackNotFound(Exception):