Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/connection.pyc

�
�Udac@sddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZd�Zd�Zd	�Zd
�Zd�Zdefd
��YZdefd��YZdS(i����N(tpartial(tto_bytestto_text(tAnsibleJSONEncoder(t	iteritems(tcPicklecCs�tj|dd�}|jdd�}ttj|�j��}tj|dt	|��tj||�tj|d|�dS(s�Handles making sure all data is properly written to file descriptor fd.

    In particular, that data is encoded in a character stream-friendly way and
    that all data gets written before returning.
    tprotocolis
s\rs%d
s%s
N(
RtdumpstreplaceRthashlibtsha1t	hexdigesttostwritetlen(tfdtobjtsrct	data_hash((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pytwrite_to_file_descriptor,scCs)tjdt|��}|j||�S(Ns!Q(tstructtpackRtsendall(tstdatat
packed_len((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyt	send_dataCscCs�d}td�}xCt|�|krW|j|t|��}|sJdS||7}qWtjd|| �d}||}xCt|�|kr�|j|t|��}|s�dS||7}qW|S(Nits!Qi(RRtrecvtNoneRtunpack(Rt
header_lenRtdtdata_len((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyt	recv_dataHs
cCst|j�}y|j|�}WnMtk
rq}t|dd�}t|d|�}|dt|dd�fSXd|dfS(NtcodeiterrRterrorstsurrogate_then_replacei(t
Connectiont_socket_pathtexec_commandtConnectionErrortgetattrR(tmoduletcommandt
connectiontouttexcR#tmessage((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyR)ZscOsAttj��}idd6|d6|d6}||f|d<|S(Ns2.0tjsonrpctmethodtidtparams(tstrtuuidtuuid4(tmethod_targstkwargstreqidtreq((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pytrequest_builderesR*cBseZd�ZRS(cOsGtt|�j|�x*t|�D]\}}t|||�q#WdS(N(tsuperR*t__init__Rtsetattr(tselfR1R:R;tktv((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyR@os(t__name__t
__module__R@(((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyR*msR'cBs5eZd�Zd�Zd�Zd�Zd�ZRS(cCs(|dkrtd��n||_dS(Nssocket_path must be a value(RtAssertionErrortsocket_path(RBRH((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyR@wscCsby|j|SWnLtk
r]|jd�rMtd|jj|f��nt|j|�SXdS(Nt_s!'%s' object has no attribute '%s'(t__dict__tKeyErrort
startswithtAttributeErrort	__class__RERt__rpc__(RBtname((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyt__getattr__|s
cOs�t|||�}|d}tjj|j�s@td��nytj|dt�}Wn)t	k
r�}tdt
|���nXy|j|�}Wn@tj
k
r�}	tddt
|	dd�d	tj���nXytj|�}
Wn�tk
r�|jd
�r(tdj||���nt|�gt|�D]\}}dj||�^q>}
d
j|
�}
tdj||
|���nX|
d|kr�td��n|
S(NR4s|socket_path does not exist or cannot be found.
See the socket_path issue category in Network Debug and Troubleshooting GuidetclssqFailed to encode some variables as JSON for communication with ansible-connection. The original exception was: %ssjunable to connect to socket. See the socket_path issue category in Network Debug and Troubleshooting GuideR$R%R&t	exceptiont
set_options;Unable to decode JSON from response to {0}. Received '{1}'.s{0}={1}s, s@Unable to decode JSON from response to {0}({1}). Received '{2}'.sinvalid json-rpc id received(R>RtpathtexistsRHR*tjsonRRt	TypeErrorRtsendtsocketterrort	tracebackt
format_exctloadst
ValueErrorRLtformattlistRtjoin(RBRPR:R;R=R<RR0R/tetresponseRCRDR5((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyt
_exec_jsonrpc�s8
	%
;cOs||j|||�}d|krt|jd�}|jd�pF|d}|d}tt|dd�d|��n|dS(s�Executes the json-rpc and returns the output received
           from remote device.
           :name: rpc method to be executed over connection plugin that implements jsonrpc 2.0
           :args: Ordered list of params passed as arguments to rpc method
           :kwargs: Dict of valid key, value pairs passed as arguments to rpc method

           For usage refer the respective connection plugin docs.
        R[RR1R#R%R&tresult(RetgetR*R(RBRPR:R;RdR$tmsgR#((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyRO�s

!cCs�yKtjtjtj�}|j|j�t|t|��t|�}WnJtjk
r�}|j	�t
ddt|dd�dtj
���nX|j	�t|dd�S(Nsunable to connect to socketR$R%R&RStsurrogate_or_strict(RZtAF_UNIXtSOCK_STREAMtconnectRHRRR"R[tcloseR*RR\R](RBRtsfRdRc((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyRY�s
.
(RERFR@RQReRORY(((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyR'us
			*	(RR	RWRZRR\R7t	functoolsRtansible.module_utils._textRRt ansible.module_utils.common.jsonRtansible.module_utils.sixRtansible.module_utils.six.movesRRRR"R)R>t	ExceptionR*tobjectR'(((sC/usr/lib/python2.7/site-packages/ansible/module_utils/connection.pyt<module>s$					

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]