%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/client/ssh/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyc

�
���^c@@s`dZddlmZmZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZdZdZ
dZdZdZd	Zd
ZdZdefd
��YZe�ZdZd�Zd�Zd�Zddd�Zd�Zd�Zd�Zddd�Z d�Z!d�Z"e#dkr\ej$e"ej%��ndS(s	
This is a shim that handles checking and updating salt thin and
then invoking thin.

This is not intended to be instantiated as a module, rather it is a
helper script used by salt.client.ssh.Single.  It is here, in a
separate file, for convenience of development.
i(tabsolute_importtprint_functionNs
salt-thin.tgzssalt-ext_mods.tgzi
iii
iiItOptionsContainercB@seZdZRS(s?
    An empty class for holding instance attribute values.
    (t__name__t
__module__t__doc__(((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyR!scC@s�d}tjjd�r7tjdk	r7tjj}n|s�ddl}y|j�d}Wntk
rpnX~|s�tj	�}n|s�tjjd�r�d}q�tjjd�r�d}q�d}q�n|S(	sR
        Get system encoding. Most of this code is a part of salt/__init__.py
    twiniNi����tdarwinsutf-8tmbcstascii(
tNonetsystplatformt
startswithtstdintencodingtlocaletgetdefaultlocalet
ValueErrortgetdefaultencoding(RR((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytget_system_encoding0s&"
		cC@stjjd�S(s?
    Simple function to return if a host is Windows or not
    R(RRR
(((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyt
is_windows`scC@s�tjjtj�r(tjtj�ntjd�}ztjtj�Wdtj|�Xt	�setj
�}tjtj�}|j|kr�t
�n|jd
@dkr�t
�ntjjd�}|rey]tjtjdt|��tjtj�}tjtj|jtjBtjBtjB�Wqbtk
r^tjjd�tjd�qbXqentjjd	jtj��tjt�dS(s�
    Salt thin needs to be deployed - prep the target directory and emit the
    delimiter and exit code that signals a required deployment.
    i?Nii�AtSUDO_GIDi����s�

Unable to set permissions on thin directory.
If sudo_user is set and is not root, be certain the user is in the same group
as the login useris{0}
deploy
i����(tostpathtexiststOPTIONStsaltdirtshutiltrmtreetumasktmakedirsRtgeteuidtstattst_uidtneed_deploymenttst_modetenvirontgettchowntinttchmodtS_IWGRPtS_IRGRPtS_IXGRPtOSErrorRtstdouttwritetexittformatt	delimitertEX_THIN_DEPLOY(t	old_umaskteuidtdstattsudo_gidtstt((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyR#gs0	

/
tsha1ic@s�ytt|�}Wn&tk
r;tdj|���nXt|d��M�|�}x0t��fd�d�D]}|j|�qsW|j�SWdQXdS(s3
    Generate a hash digest string for a file.
    sInvalid hash type: {0}trbc@s
�j��S(N(tread((t
chunk_sizetifile(s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyt<lambda>�stN(	tgetattrthashlibtAttributeErrorRR1topentitertupdatet	hexdigest(RtformR<t	hash_typethash_objtchunk((R<R=s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytget_hash�s
	"cC@s�tjj|�}tjd�}|jdtj�|j�tj|�ytj	|�Wnt
k
ronXttj�dS(s'
    Unpack the Salt thin archive.
    i?RN(ttarfiletTarFiletgzopenRRt
extractallRRtclosetunlinkR-t
reset_time(t	thin_pathttfileR4((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytunpack_thin�s


cC@s-tjjdjtj��tjt�dS(s;
    Signal that external modules need to be deployed.
    s
{0}
ext_mods
N(RR.R/R1RR2R0t
EX_MOD_DEPLOY(((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytneed_ext�scC@s�tjjtjdddddd�}tjj|�}tjd�}|j	d|�|j
�tj|�tj|�tjj|d	�}tjjtjd	�}tj
||�d
S(s&
    Unpack the external modules.
    trunning_datatvartcachetsalttminiontextmodsi?Rtext_versionN(RRtjoinRRRLRMRNRRORPRQRtmove(text_pathtmodcacheRTR4tver_pathtver_dst((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyt
unpack_ext�s"		


t.cC@s�|sttj��}nxgtj|�D]V}tjj||�}tjj|�rkt|d|�ntj|||f�q+WdS(sf
    Reset atime/mtime on all files to prevent systemd swipes only part of the files in the /tmp.
    tamtN(	R(ttimeRtlistdirRR_tisdirRRtutime(RRgtfname((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyRR�sc

C@s�i}ttjjtjd���X}xN|j�D]@}|j�jd�\}}}t	|�t	|�f||<q4WWdQXt
jdddddd	d
f}xK|D]C}|d}tj
|dtjd
tjdt�j�\}	}
t
jddkr-t
jddkr-|	jt�d�j�}	n!|	jdt�dd�j�}	|	sZq�ntg|	jd�D]}t	|�^qm�}x^|D]V}|d||dkr�|||kr�tjjtjjtj|��r�|Sq�Wq�Wt
jt�dS(sL
    Find executable which matches supported python version in the thin
    ssupported-versionst:Ntpython3tpython27s	python2.7tpython26s	python2.6tpython2tpythonsY -c  "import sys; sys.stdout.write('%s:%s' % (sys.version_info[0], sys.version_info[1]))"R.tstderrtshelliiiitreplaceRterrors(RCRRR_RRt	readlineststriptsplitR(Rt
executablet
subprocesstPopentPIPEtTruetcommunicatetversion_infotdecodeRttupleRR0tEX_THIN_PYTHON_INVALID(
tpymapt_fptlinetnstv_majtv_mintpycmdstpy_cmdtcmdR.t_txtc_vn((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytget_executable�s&!&!

3&!.
LcC@s�tjjtjt�}tjj|�r\tjt|tj	�krOt
�nt|�n�tj
jd�s�tjdddg�j�}|dkr�tjt�q�ntjjtj�rtjjtj�rtjjdjtj��tjt�ntjjtj�s!t
�ntjjtjjtjd��}tjj|�sktjj|�r�tjjdj|��t
�nt|d	��}|j�j�}Wd
QX|tjkr�tjjdj|tj��t
�ntjjtjd�}tjj|�s=tjjd
j|��t
�nttjjtjd�d��}|jtjd�Wd
QXtj rItjjtjt!�}tjj|�r�t"|�qItjjtjd�}	tjj|	�s�tjj|	�rt#�nt|	d	��}|j�j�}
Wd
QX|
tj krIt#�qInt$t%�dkrnt%dj&�}nt%}t'�|ddddddddtjg}y0|djd�r�|j(|j)d��nWnt*t+fk
r�nX|j(d�|j,|�tjjdj|��tj-jtj.d�tj-j/�tj0srtjjtj.d�tjj/�ntj1d
k	r�tj3tj1�}
ntj0r,tj|dtj4dtj4�}|j5�\}}tj-j|j6d t7�d!d"��tj-j/�|j8}tj9rft:j;tj�qfn:tj9rWtj<|�}t:j;tj�ntj<|�}tj1d
k	r�tj3|
�n|S(#s
    Main program body
    Rs/bin/shs-cscommand -v scpis5ERROR: salt path "{0}" exists but is not a directory
s
code-checksums6WARNING: Unable to locate current code checksum: {0}.
trNs8WARNING: current code checksum {0} is different to {1}.
s	salt-callsERROR: thin is missing "{0}"
R\tws
R^is--retcode-passthroughs--locals
--metadatas--outtjsons-ltquieti����s--no-parse=s--sSALT_ARGV: {0}
R.RsRRvRu(=RRR_RRtTHIN_ARCHIVEtisfiletchecksumRKthashfuncR#RURRR
R{R|twaitR0tEX_SCP_NOT_FOUNDRRjRsR/R1tEX_CANTCREATtnormpathRCtreadlineRxt
code_checksumtconfigtext_modstEXT_ARCHIVEReRWtlentARGSRyR�tappendtpopt
IndexErrort	TypeErrortextendR.R2tflushtttyt	cmd_umaskR
RR}RR�Rt
returncodetwipeRRtcall(targvRStscpstattcode_checksum_pathtvpotcur_code_cstsalt_call_pathR�Ratversion_pathtcur_versiont
argv_preparedt	salt_argvR4tprocR.R�tretcode((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pytmain�s�

+	

$&



$	
&




		!%
			t__main__(&Rt
__future__RRRARLRRRR!R{RhR�R�R�R3tEX_THIN_CHECKSUMRVR�R�tobjectRRR
R�RRR#RKRURWReRRR�R�RR0R�(((s?/usr/lib/python2.7/site-packages/salt/client/ssh/ssh_py_shim.pyt<module>	s@		0		)			
		q

Zerion Mini Shell 1.0