%PDF- %PDF-
Mini Shell

Mini Shell

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

a

�)g�-�	@s<ddlmZmZmZeZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlmZmZejddkZe�de
j�e��e�ejdd�ejdd���e��\ZZ d	a!d
d�Z"ddd
�Z#dd�Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*e+dk�r8e*�dS)�)�absolute_import�division�print_functionN)�to_text�to_bytes�z
ansible-%szInvoked with %s� ��cCst�tj|�dS�N)�syslog�
LOG_NOTICE)�msg�r�A/usr/lib/python3.9/site-packages/ansible/modules/async_wrapper.py�notice$srcCs.|durtt�|��tj��t�|�dSr)�print�json�dumps�sys�stdout�flush�exit)�resZexit_msgrrr�end(s
rcCszt��}|dkrt�Wn:tyTt��d}td|j|jfdd�d�Yn0t��t�	t
dd��zt��}|dkr�t�Wn:ty�t��d}td|j|jfdd�d�Yn0td	d
�}t�|�
�tj�
��t�|�
�tj�
��t�|�
�tj�
��dS)Nrr	zfork #1 failed: %d (%s)
T)r�failedZ022�zfork #2 failed: %d (%s)
z	/dev/null�w)�os�forkr�OSErrorr�exc_info�errno�strerror�setsid�umask�int�open�dup2�fileno�stdinr�stderr)�pid�eZdev_nullrrr�daemonize_self/s(
"
"
r.cCs�g}|��}t|�D]\}}|��}|�d�rq<qtd��||d�}tt|��D]\}}|���d�rTqxqTtd��|dkr�|t|�|d�}|�dd�	|��|dt|�|�}d�	|�|fS)	a\
    Used to filter unrelated output around module JSON output, like messages from
    tcagetattr, or where dropbear spews MOTD on every single command (which is nuts).

    Filters leading lines before first line-starting occurrence of '{', and filter all
    trailing lines after matching close character (working from the bottom of output).
    �{zNo start of json char foundN�}zNo end of json char foundrz2Module invocation had junk after the JSON data: %s�
)
�
splitlines�	enumerate�strip�
startswith�
ValueError�reversed�endswith�len�append�join)�data�warnings�lines�start�lineZreverse_end_offsetZ
trailing_junkrrr�_filter_non_json_linesPs"
rAcCstt|d��V}|�d�}|dd�dkr6Wd�dS|d|�d�����d�Wd�S1sf0YdS)N�rbir�s#!�
� )r'�read�indexr4�split)Zmodule_pathZ	module_fd�headrrr�_get_interpreterxs

rJc
CsFzt�|�Wn2ty@}z|jtjkr,�WYd}~n
d}~00dSr)r�makedirsr r"ZEEXIST)�pathr-rrr�_make_temp_dir�s
rMc
Cs�td}t|d�}znz|�t�|��Wn@ttfyh}z$td|t|�f�|�WYd}~n
d}~00W|�	�t
�|t�n|�	�t
�|t�0dS)Nz.tmprzfailed to write to %s: %s)�job_pathr'�writerr�IOErrorr r�str�closer�rename)�infoZjobfileZtjobr-rrr�jwrite�s
�rUc	Cs�tdd|d��i}t�d�t��d}d}d}z�dd�t�|�D�}t|d�}|r`||}tj|dtj	tj	tj	d	�}|�
�\}}tr�|�d
d�}|�d
d�}t
|�\}}	t�|�}|	r�|�dg�}
t|
t�s�|
g}
|
�|	�|
|d<|r�||d
<t|�Wn�ttf�yHt��d}d|t|�||d�}||d<t|�Yn<ttf�y�d|||t��d�}||d<t|�Yn0dS)Nr	r)�started�finished�ansible_job_idTr
cSsg|]}t|dd��qS)Zsurrogate_or_strict)�errors)r)�.0�crrr�
<listcomp>��z_run_module.<locals>.<listcomp>F)�shellr*rr+zutf-8�surrogateescaper=r+)r�cmdr�outdatar+rX)rr`r<r+r)rU�ipc_notifier�sendrR�shlexrHrJ�
subprocess�Popen�PIPEZcommunicate�PY3�decoderAr�loads�get�
isinstance�list�extendr rPrr!rr6�	Exception�	traceback�
format_exc)Zwrapped_cmd�jid�resultraZfiltered_outdatar+r`ZinterpreterZscriptZ
json_warningsZmodule_warningsr-rrr�_run_module�sb
�


��rtc
CsHttj�dkrtddd�d�dtjdt��f}tjd}tjd}tjd	}d
tj�|�vrhd}n"ttj�dkr�tjddk}nd}|d
kr�d||f}n|}d}tj�	dd�}tj�
|�}tj�||�azt
|�WnLt�y(}	z2tdd|t|	�ftt���d�d�WYd}	~	n
d}	~	00�z�t��}
|
�r�t��d}|dk�rtt�d��rd�qtn|d}�qH�qHtd�tddd|t|d�d��n`t��t�td�t��}|�r�t��t��t|�}
t�||�td||
f�t�|�t�|tj�dk�r�td||
f�t�|�|
|}
|
dk�r�dd|d�}t|�td|�t� |t!j"�td|�t�d�|�s�t#�$tj�|�d�t|��q�td �|�s�t#�$tj�|�d�t�n*td!t���t%||�td"t���WnFt�yB}	z,td#|	�tdd$|	d�d%�WYd}	~	n
d}	~	00dS)&N�Tzpusage: async_wrapper <jid> <time_limit> <modulescript> <argsfile> [-preserve_tmp]  Humans, do not call directly!)rrr	z%s.%drCr�z-tmp-z
-preserve_tmpF�_z%s %sZANSIBLE_ASYNC_DIRz~/.ansible_asyncz#could not create directory: %s - %s)rr�	exception�rg�������?z"Return async_wrapper task started.)rrVrWrXZresults_fileZ_ansible_suppress_tmpdir_deletezStarting module and watcherzStart watching %s (%s))rrz%s still running (%s)zTimeout exceeded)rrZ	child_pidzTimeout reached, now killing %szSent kill to group %s zDone in kid B.zStart module (%s)zModule complete (%s)z	error: %szFATAL ERROR: %sz async_wrapper exited prematurely)&r9r�argvrr�getpidrL�dirname�environrk�
expanduserr;rNrMrorrprqrrbrR�ipc_watcherZpollrr.r&�setpgid�time�sleep�waitpid�WNOHANGrU�killpg�signal�SIGKILL�shutil�rmtreert)rrZ
time_limitZwrapped_moduleZargsfileZpreserve_tmpr`�stepZ	async_dirZjobdirr-r,ZretriesZsub_pidZ	remainingrrrr�main�s���



��	

��




r��__main__)Nr),Z
__future__rrr�typeZ
__metaclass__r"rrdr�rrerrpr�r�rZmultiprocessingZansible.module_utils._textrr�version_inforhZopenlogrL�basename�__file__r
r;rzZPiperrbrNrrr.rArJrMrUrtr��__name__rrrr�<module>s>"
!(	E


Zerion Mini Shell 1.0