%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3.9/site-packages/ansible/plugins/shell/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3.9/site-packages/ansible/plugins/shell/__pycache__/__init__.cpython-39.pyc

a

�)gu%�@s�ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZmZddlmZmZddlmZe	�d�ZGd	d
�d
e�ZdS)�)�absolute_import�division�print_functionN)�AnsibleError)�	to_native)�	text_type�string_types)�Mapping�Sequence)�
AnsiblePluginz^~[_.A-Za-z0-9][-_.A-Za-z0-9]*$cs�eZdZ�fdd�Zdd�Zd/�fdd�	Zedd	��Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd0dd�Zdd�Zd1d d!�Zd2d#d$�Zd%d&�Zd3d'd(�Zd)d*�Zd+d,�Zd-d.�Z�ZS)4�	ShellBasecs$tt|���i|_d|_d|_dS�N)�superr�__init__�env�tmpdir�
executable��self��	__class__��B/usr/lib/python3.9/site-packages/ansible/plugins/shell/__init__.pyr%szShellBase.__init__cCsHdd�|�d�D�}tdd�|D��s8td�t|����|�d|�dS)NcSsg|]}|�d��qS)�/)�rstrip��.0�drrr�
<listcomp>1�z7ShellBase._normalize_system_tmpdirs.<locals>.<listcomp>�system_tmpdirscss|]}tj�|�VqdSr
)�os�path�isabsrrrr�	<genexpr>5rz6ShellBase._normalize_system_tmpdirs.<locals>.<genexpr>z`The configured system_tmpdirs contains a relative path: {0}. All system_tmpdirs must be absolute)�
get_option�allr�formatrZ
set_option)rZnormalized_pathsrrr�_normalize_system_tmpdirs-s�z#ShellBase._normalize_system_tmpdirsNcs�tt|�j|||d�|�d�}t|t�r2td��t|t�sB|g}|D]*}t|t�sdtdt	|���|j
�|�qFz|��Wnt
y�Yn0dS)N)�	task_keys�var_options�directZenvironmentzUThe "envirionment" keyword takes a list of dictionaries or a dictionary, not a stringzfThe "envirionment" keyword takes a list of dictionaries (or single dictionary), but got a "%s" instead)rr�set_optionsr%�
isinstancerrr
r	�typer�updater(�KeyError)rr)r*r+rZenv_dictrrrr,;s



zShellBase.set_optionscCsdt��t��t�dd�fS)Nzansible-tmp-%s-%s-%srl)�timer!�getpid�randomZrandintrrrr�_generate_temp_dir_nameSsz!ShellBase._generate_temp_dir_namecKsd�dd�|��D��S)N� cSs&g|]\}}d|t�t|��f�qS)z%s=%s)�shlex�quoter)r�k�vrrrrXrz(ShellBase.env_prefix.<locals>.<listcomp>)�join�items)r�kwargsrrr�
env_prefixWszShellBase.env_prefixcGstjj|�Sr
)r!r"r:)r�argsrrr�	join_pathZszShellBase.join_pathcCstj�|���}|��Sr
)r!r"�basename�strip)r�pathname�	base_namerrr�get_remote_filename^szShellBase.get_remote_filenamecCs
|�d�S)Nr)�endswith)rr"rrr�path_has_trailing_slashbsz!ShellBase.path_has_trailing_slashcCs*d|g}|�|�dd�|D�}d�|�S)N�chmodcSsg|]}t�|��qSr�r6r7�r�crrrrhrz#ShellBase.chmod.<locals>.<listcomp>r5��extendr:)r�paths�mode�cmdrrrrGes
zShellBase.chmodcCs*d|g}|�|�dd�|D�}d�|�S)N�chowncSsg|]}t�|��qSrrHrIrrrrorz#ShellBase.chown.<locals>.<listcomp>r5rK)rrM�userrOrrrrPls
zShellBase.chowncCs*d|g}|�|�dd�|D�}d�|�S)N�chgrpcSsg|]}t�|��qSrrHrIrrrrvrz#ShellBase.chgrp.<locals>.<listcomp>r5rK)rrM�grouprOrrrrRss
zShellBase.chgrpcCs4ddd||fg}|�|�dd�|D�}d�|�S)z5Only sets acls for users as that's really all we needZsetfaclz-mzu:%s:%scSsg|]}t�|��qSrrHrIrrrr~rz+ShellBase.set_user_facl.<locals>.<listcomp>r5rK)rrMrQrNrOrrr�
set_user_faclzs
zShellBase.set_user_faclFcCs,t�|�}d}|r|d7}|d||jfS)Nzrm -f z-r z%s %s)r6r7Z_SHELL_REDIRECT_ALLNULL)rr"ZrecurserOrrr�remove�s

zShellBase.removecCsddt�|�g}d�|�S)N�testz-er5)r6r7r:)rr"rOrrr�exists�szShellBase.exists�c	Cs�|s|j��}|rD|r |�d�}||�d�vr4|}q\|�d�d}n|durX|�d�}n|}|�||�}d|j||jf}|d|j|j||jf7}|d|j||j||jf7}|r�d|@}d	|j||j||j	f}|S)
Nrr rZ
remote_tmpzmkdir -p %s echo %s %sz%s mkdir %s echo %s %sz %s echo %s=%s echo %s %si�z%s umask %o %s %s %s)
rr4rr%r?�_SHELL_SUB_LEFT�_SHELL_SUB_RIGHT�
_SHELL_ANDZ_SHELL_GROUP_LEFTZ_SHELL_GROUP_RIGHT)	rZbasefile�systemrNrZ
basetmpdirZbasetmprOZ	tmp_umaskrrr�mkdtemp�s&


zShellBase.mkdtemp�cCs2|dkrt�|�s*t�|�}n|r*||7}d|S)a� Return a command to expand tildes in a path

        It can be either "~" or "~username". We just ignore $HOME
        We use the POSIX definition of a username:
            http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_426
            http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap03.html#tag_03_276

            Falls back to 'current working directory' as we assume 'home is where the remote user ends up'
        �~zecho %s)�_USER_HOME_PATH_RE�matchr6r7)rZuser_home_path�usernamerrr�expand_user�s
zShellBase.expand_usercCsd|j|jfS)z-Return the working directory after connectingzecho %spwd%s)rYrZrrrr�pwd�sz
ShellBase.pwdcCsh|��dkrt�|�}g}|r0|�dd���}nd}|�|��||g�|durZ|�|�d�|�}|S)Nr^z#!r5)rAr6r7�replacerL�appendr:)rZ
env_stringZshebangrOZarg_pathZ	cmd_partsZnew_cmdrrr�build_module_command�s


zShellBase.build_module_commandcCs|jr|d|j|f7}|S)z6Append an additional command if supported by the shellz %s %s)r[)rrOZ
cmd_to_appendrrr�append_command�szShellBase.append_commandcCs|S)z_wrap script execution with any necessary decoration (eg '&' for quoted powershell script paths)r�rrOrrr�
wrap_for_exec�szShellBase.wrap_for_execcCs
t�|�S)z[Returns a shell-escaped string that can be safely used as one token in a shell command linerHrirrrr7�szShellBase.quote)NNN)F)NFrXN)r^)N)�__name__�
__module__�__qualname__rr(r,�staticmethodr4r=r?rDrFrGrPrRrTrUrWr]rcrdrgrhrjr7�
__classcell__rrrrr$s,


*

r)Z
__future__rrrr.Z
__metaclass__r!Zos.pathr3�rer6r1Zansible.errorsrZansible.module_utils._textrZansible.module_utils.sixrrZ/ansible.module_utils.common._collections_compatr	r
Zansible.pluginsr�compiler`rrrrr�<module>s


Zerion Mini Shell 1.0