
    Vh&                       d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dl	m
Z
 d dlmZmZ d dlmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ ej4                  j7                         D  ci c]$  \  } }| j9                         |j9                         & c}} Z e       Z ej>                  d      Z  G d de!      Z"d Z#d Z$d Z%yc c}} w )    )annotationsN)	constants)AnsibleError)	to_nativeto_text)LinuxDistribution)Display)get_versioned_doclink)LooseVersion)Distribution)
format_excz((?s)PLATFORM[\r\n]+(.*)FOUND(.*)ENDFOUNDc                  *     e Zd Z fdZd Zd Z xZS )!InterpreterDiscoveryRequiredErrorc                H    t         t        |   |       || _        || _        y N)superr   __init__interpreter_namediscovery_mode)selfmessager   r   	__class__s       V/home/dcms/DCMS/lib/python3.12/site-packages/ansible/executor/interpreter_discovery.pyr   z*InterpreterDiscoveryRequiredError.__init__   s#    /?H 0,    c                    | j                   S r   r   r   s    r   __str__z)InterpreterDiscoveryRequiredError.__str__!   s    ||r   c                    | j                   S r   r   r   s    r   __repr__z*InterpreterDiscoveryRequiredError.__repr__$   s    ||r   )__name__
__module____qualname__r   r   r    __classcell__)r   s   @r   r   r      s    -
r   r   c                d   |dk7  rt        dj                  |            |j                  dd      }d }d}dg}|j                  d      }|j	                  d      }		 t
        j                  j                  d|	      }
t
        j                  j                  d
|	      }t        j                  dj                  |      |       |D cg c]  }d|z  	 }}dj                  dj                  |            }| j                  |d      }|j                  dd      }t        j                  |      }|s1t        j                  dj                  |      |       t        d      |j                         d   j!                         j#                         }|j                         d   j%                         D cg c]$  }|j                  d      s|j#                         & }}t        j                  dj                  |      |       |s.|	s+| j&                  j)                  dj                  ||             y|dk7  r#t+        dj                  t-        |                  t/        j0                  dd      }| j2                  j4                  r| j                  |d   d|       }nt+        d!      t7        j8                  |j                  d            }t;        |      \  }}|r|st+        d"      t<        j                  |j!                         j#                               }|
j                  |j!                         j#                               xs |
j                  |      }|st+        d#j                  |            t?        tA        ||      d$%      }|rC|dk7  r>d|v r:|	s7| j&                  j)                  d&j                  ||||tC        d'                   y||vrs||vr-|	s+| j&                  j)                  d(j                  ||             |	s;| j&                  j)                  d)j                  |||||d   tC        d'                   |d   S |S c c}w c c}w # t*        $ r9}t        j                  d*j                  t?        |            |       Y d }~nd }~wtD        $ r  tF        $ r}|	st        jI                  d+j                  |t?        |            ,       t        j                  d-j                  t?        tK                           |       |rO|j                  d.      r>t        j                  d/j                  t?        |j                  d.                  |       Y d }~nd }~ww xY w|	s9| j&                  j)                  d0j                  |||d   tC        d'                   |d   S )1Npythonz+Interpreter discovery not supported for {0}inventory_hostnameunknownz/usr/bin/python3auto_legacy_silent_INTERPRETER_PYTHON_DISTRO_MAP)	variablesINTERPRETER_PYTHON_FALLBACKz$Attempting {0} interpreter discovery)msghostzcommand -v '%s'z4echo PLATFORM; uname; echo FOUND; {0}; echo ENDFOUNDz; F)sudoablestdout z%raw interpreter discovery output: {0})r/   z3unexpected output from Python interpreter discoveryr      /zfound interpreters: {0}z5No python interpreters found for host {0} (tried {1})linuxz0unsupported platform for extended discovery: {0}zansible.executor.discoveryzpython_target.py)r0   in_dataz>pipelining support required for extended interpreter discoveryz-unable to get Linux distribution/version infoz#unsupported Linux distribution: {0}surrogate_or_strict)errorszDistribution {0} {1} on host {2} should use {3}, but is using /usr/bin/python3 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.)&
ValueErrorformatget
startswithendswithCconfigget_config_valuedisplayvvvjoin_low_level_execute_commandfoundrematchdebuggroupslowerstrip
splitlines_discovery_warningsappendNotImplementedErrorr   pkgutilget_data_connectionhas_pipeliningjsonloads_get_linux_distroOS_FAMILY_LOWERr   _version_fuzzy_matchr
   r   	Exceptionwarningr   )actionr   r   	task_varsr/   resplatform_typefound_interpretersis_auto_legacy	is_silentplatform_python_mapbootstrap_python_listpycommand_listshell_bootstrap
raw_stdoutrG   interpplatform_scriptplatform_infodistroversionfamilyversion_mapplatform_interpreterexs                             r   discover_interpreterrq   )   s^    8#FMMN^_``==-y9D
CM-.#..}=N''	2Ic|hh778Xdm7n ! 9 9:Wcl 9 m?FFGWX_cd :OO2)B.OOPWWX\XaXabnXop //%/PWWXs+
j)MMBII*U\`MaRSSq)//1779;@<<>!;L;W;W;Yt]c]n]nor]sfllntt0778JKRVW!**11 3JJP&QUWlJmo 'G#%&X&_&_`ijw`x&yzz!**+GI[\ ,,334Fq4ITYcr3sC &&fgg

3778#45+M:W%&UVV $$V\\^%9%9%;<)--flln.B.B.DEhI\I`I`agIh%&K&R&RSY&Z[[&';G['QZop #'::?RVh?h ..558  7K 56g hj	k +'99#+@@ .. f!'(<d!CE **V 5 $VFGT;OQcdeQf$9:k$lno
 &a((##e P  uF  gFMMgVXkZaeff  |OO d k klpryz|r} ~OMMFMMgV`VbNcdkoMpswwx( L S ST[\_\c\cdl\mTn ovz{| ""V - VM41CA1F12cdfg
 a  s`   A,Q QC!Q 5QQAQ 6F Q A6Q Q 
Q 	U/#/RU/,B9U**U/c                   | j                  dg       }t        |      dk(  rt        |      r
|d   |d   fS | j                  d      }|syt        j                  |      }|j                  dd      |j                  d	d      fS )
Nplatform_dist_result   r   r3   osrelease_content)r2   r2   idr2   
version_id)r<   lenanyr   _parse_os_release_content)rj   dist_resultru   osrs       r   rV   rV      s    ##$:B?K
;1[!11~{1~--%))*=>

5
56G
HC774sww|S999r   c                `   |j                  |       }|r|S t        |j                         D cg c]  }t        |       c}      }t        |       }t	        j                  ||      }|dk(  r|j                  |d   j
                        S |j                  ||dz
     j
                        S c c}w )Nr   r3   )r<   sortedkeysr   bisectvstring)rl   rn   r]   vsorted_looseversionsfind_looseversionkposs          r   rX   rX      s    
//'
"C

!K<L<L<N"Oq<?"OP$W- ==-/@ADqy 3A6>>??
 ??/q9AABB #Ps   B+)&
__future__r   r   rT   rP   reansibler   r?   ansible.errorsr   +ansible.module_utils.common.text.convertersr   r   ansible.module_utils.distror   ansible.utils.displayr	   ansible.utils.plugin_docsr
   #ansible.module_utils.compat.versionr   .ansible.module_utils.facts.system.distributionr   	tracebackr   	OS_FAMILYitemsrJ   rW   rB   compilerF   rY   r   rq   rV   rX   )kr   s   00r   <module>r      s    #    	 " ' J 9 ) ; < G  4@4J4J4P4P4RSDAq1779aggi'S
)
"**@
A	 !D: CM Ts   ,)C