a )g&@sddlmZmZmZeZddlZddlZddlZddl Z ddl m Z ddl mZmZddlmZddlmZddlmZddlmZdd lmZdd lmZd d ejDZeZe d Z!Gddde"Z#ddZ$ddZ%ddZ&dS))absolute_importdivisionprint_functionN) constants) to_nativeto_text)LinuxDistribution)Display)get_versioned_doclink LooseVersion) Distribution) format_exccCsi|]\}}||qS)lower).0kvrrJ/usr/lib/python3.9/site-packages/ansible/executor/interpreter_discovery.py rz((?s)PLATFORM[\r\n]+(.*)FOUND(.*)ENDFOUNDcs,eZdZfddZddZddZZS)!InterpreterDiscoveryRequiredErrorcs tt||||_||_dSN)superr__init__interpreter_namediscovery_mode)selfmessagerr __class__rrrsz*InterpreterDiscoveryRequiredError.__init__cCs|jSrrrrrr__str__!sz)InterpreterDiscoveryRequiredError.__str__cCs|jSrr!r"rrr__repr__$sz*InterpreterDiscoveryRequiredError.__repr__)__name__ __module__ __qualname__rr#r$ __classcell__rrrrrs rc Cs|dkrtd||dd}d}d}dg}|d}|d} ztjjd|d } tjjd |d } tj d ||d d d| D} dd | } |j | dd}|dd}t |}|stjd||dtd|d}dd|dD}tjd||d|sF| s@|jd|| WdS|dkrbtdt|tdd }|jjr|j |dd|d!}ntd"t|d}t|\}}|r|std#t|}| |p| |}|s td$|tt ||d%d&}|r`|dkr`d|vr`| sZ|jd'||||t!d(WdS||vr|| vr| s|jd)||| s|jd*|||||dt!d(|dWS|WSty}z$tj d+t||d WYd}~nd}~0t"y}zt| s|tj#d,|t|d-tjd.tt$|d |r||d/r|tj d0t|d/|d WYd}~n d}~00| s|jd1|||dt!d(|dS)2NZpythonz+Interpreter discovery not supported for {0}Zinventory_hostnameunknownz/usr/bin/pythonZ auto_legacyZ_silentZ_INTERPRETER_PYTHON_DISTRO_MAP)Z variablesZINTERPRETER_PYTHON_FALLBACKz$Attempting {0} interpreter discovery)msghostcSsg|] }d|qS)zcommand -v '%s'r)rpyrrr Crz(discover_interpreter..z4echo PLATFORM; uname; echo FOUND; {0}; echo ENDFOUNDz; F)sudoablestdoutz%raw interpreter discovery output: {0})r+z3unexpected output from Python interpreter discoveryrcSsg|]}|dr|qS)/) startswithstrip)rZinterprrrr-Srzfound interpreters: {0}z5No python interpreters found for host {0} (tried {1})Zlinuxz0unsupported platform for extended discovery: {0}zansible.executor.discoveryzpython_target.py)r.Zin_dataz>pipelining support required for extended interpreter discoveryz-unable to get Linux distribution/version infoz#unsupported Linux distribution: {0}Zsurrogate_or_strict)errorszDistribution {0} {1} on host {2} should use {3}, but is using /usr/bin/python for backward compatibility with prior Ansible releases. See {4} for more informationz/reference_appendices/interpreter_discovery.htmlzCPlatform interpreter {0} on host {1} is missing from bootstrap listzDistribution {0} {1} on host {2} should use {3}, but is using {4}, since the discovered platform python interpreter was not present. See {5} for more information.z+Python interpreter discovery fallback ({0})zAUnhandled error in Python interpreter discovery for host {0}: {1})r*z$Interpreter discovery traceback: {0}stderrz(Interpreter discovery remote stderr: {0}zPlatform {0} on host {1} is using the discovered Python interpreter at {2}, but future installation of another Python interpreter could change the meaning of that path. See {3} for more information.)% ValueErrorformatgetr2endswithCZconfigZget_config_valuedisplayZvvvjoinZ_low_level_execute_commandfoundrematchdebuggroupsrr3 splitlinesZ_discovery_warningsappendNotImplementedErrorrpkgutilget_dataZ _connectionZhas_pipeliningjsonloads_get_linux_distroOS_FAMILY_LOWERr_version_fuzzy_matchr ExceptionZwarningr)actionrrZ task_varsr+resZ platform_typeZfound_interpretersZis_auto_legacyZ is_silentZplatform_python_mapZbootstrap_python_listZ command_listZshell_bootstrapZ raw_stdoutr?Zplatform_script platform_infoZdistroversionZfamily version_mapZplatform_interpreterexrrrdiscover_interpreter)s               ,4 rScCsd|dg}t|dkr0t|r0|d|dfS|d}|sBdSt|}|dd|d dfS) NZplatform_dist_resultrr4osrelease_content)r0r0idr0Z version_id)r9lenanyrZ_parse_os_release_content)rOZ dist_resultrUZosrrrrrIs   rIcCsh||}|r|Stdd|D}t|}t||}|dkrT||djS|||djS)NcSsg|] }t|qSrr )rrrrrr-rz(_version_fuzzy_match..rr4)r9sortedkeysr bisectZvstring)rPrQrNZsorted_looseversionsZfind_looseversionZkposrrrrKs  rK)'Z __future__rrrtypeZ __metaclass__r[rGrEreZansiblerr;Zansible.module_utils._textrrZansible.module_utils.distrorZansible.utils.displayr Zansible.utils.plugin_docsr Z#ansible.module_utils.compat.versionr Z.ansible.module_utils.facts.system.distributionr tracebackrZ OS_FAMILYitemsrJr<compiler>rLrrSrIrKrrrrs*