%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/gitfs.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlZddlmZddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Zddl!Zddl"Zddl#Zddl$m%Z&ddl'm(Z(ddl)m*Z+ddl,m-Z-m.Z.m/Z/dd	l0m1Z1dd
l"m2Z3ddl4m5Z5e&dZ6d
fZ7fZ8dZ9dfZ:ddddddfZ;dddfZ<dZ=dZ>dZ?ej@eA�ZBy+ddlCZCddlDZDe3eCjE�ZFWneGk
r�eHZFnXy�ddlIZIeIjJ��eIjKd�ddlLZLWdQXe3eLjE�ZMe3eLjN�ZNeMe3d�krfyddlOZLddlPZLWneQk
rMnXd�ZReReLjS_TnyeLjUjVZVWneWk
r�eGZVnXWn?eGk
r�ZXeHZMeHZNeYeXeQ�r�eBjZd�nnXe3d �Z[e3d!�Z\e3d"�Z]d#�Z^d$�Z_d%e`fd&��YZad'eafd(��YZbd)eafd*��YZciecd6ebd+6Zdd,e`fd-��YZed.eefd/��YZfd0eefd1��YZgd2eefd3��YZhdS(4uJ
Classes which provide the shared base for GitFS, git_pillar, and winrepo
i(tabsolute_importtprint_functiontunicode_literalsN(tdatetime(tDEFAULT_MASTER_OPTS(tOrderedDict(t
os_is_running(tFileserverConfigErrortGitLockErrortget_error_message(ttagify(tLooseVersion(tsixugitfs_ref_typesunameidupygit2uuserupasswordupubkeyuprivkeyu
passphraseu
insecure_authu
mountpointurooturefugGitPython is installed, you may wish to set %s_provider to 'gitpython' to use GitPython for %s support.ubpygit2 is installed, you may wish to set %s_provider to 'pygit2' to use pygit2 for for %s support.u�Cache path %s (corresponding remote: %s) exists but is not a valid git repository. You will need to manually delete this directory on the master to continue to use this %s remote.uignoreu0.26.3cC@s#|s
dStjj|�jd�S(Nuutf-8(tNonetpygit2tffitstringtdecode(tptr((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt__maybe_stringysuFailed to import pygit2u0.3u0.20.3u0.20.0c@sli
td6td6td6dd6dd6dd6dd6dd	6dd
6td6��fd�}|�kr�||�}|dkr�tj|�Sn�|}|dkr't|tjtf�s�tj|�}nt|tj�rg|jd
�D]}|j	�^q�Sg|D]}tj|�^qSy||�SWn0t
k
rg}tjd||�tj|�SXdS(uO
    Force params to be strings unless they should remain a different type
    u
ssl_verifyu
insecure_authudisable_saltenv_mappingu
stringlistu
env_whitelistu
env_blacklistusaltenv_whitelistusaltenv_blacklisturefspecsu	ref_typesuupdate_intervalc@svxo�D]a}y!|jd|�r-|}PnWqtk
rg|jdtj|��rh|}PqhqXqWd}|S(Nu_(tendswitht	TypeErrorRt	text_typeR
(tkeytitemtret(tnon_string_params(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_find_global�s

u,uGFailed to enforce type for key=%s with val=%s, falling back to a stringN(
tbooltintR
RRt
isinstancetstring_typestlisttsplittstript	Exceptiontlogterror(RtvalRtexpectedtxtexc((Rs4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
enforce_types�s<

& 
cC@stdj|���dS(u7
    Fatal configuration issue, raise an exception
    uFailed to load {0}N(Rtformat(trole((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytfailhard�stGitProvidercB@s.eZdZdd�Zd�Zdd�Zed��Zd�Zd�Z	dd	�Z
d
�Zd�Zde
d�Zd
�Zejdddd��Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zed��Zd�Z d�Z!d�Z"RS( u�
    Base class for gitfs/git_pillar provider classes. Should never be used
    directly.

    self.provider should be set in the sub-class' __init__ function before
    invoking the parent class' __init__.
    ugitfsc
@s[||_||_tjjj|jjdj|j�g�dtdtdt	j
dd��|_tj
|�|_xZt	j|j�D]F\}}	d|	kr�tjjj|j|d�|j|d<q�q�Wg|D]}
|
|kr�|
^q�}|rtjdd	j|��ny||�Wn'tk
rPt|�t|��nXt|t�r�tt|��|_|j�tjjj||jdtdtdt	j
dt�}|s�tjd
|j|j�t|j�nt}
x��fd�|D�D]�}t}
|t kr�|j!t"kr�dj|j||jd	jt"�|j!�}|jd
krr|d7}ntj|�qdj|j||jd	j���}|jd
kr�|d7}ntj|�qW|
r�t|j�n|jj#|�n||_|j�d|jkr1d|jd<n|jdkr�d|jkr�|jj$dd�d|jd<|jdj%�j&d�r�|jdd |jd<q�nd|jkr�tjjj|jd�j'd�|jd<n
d|jd<d|jkri|jd<ndxat	j|jd�D]I\}}	d|	kr*|jd|}tjjj|d�|d<q*q*WxOt	j|j�D];\}}|t(kr�t)||�r�t*|||�q�q�WxEt(D]=}|dkrt*|d||j|�n|j+|�q�Wt)|d�s�dj|j�}yt,|}Wn.t-k
rptjd|�t|j�nXt*|d|�tj.d ||j|j�nxad1D]Y}t/||d�}|r�tjj1j2d#d$j|��t*|d%j|�|�q�q�Wt3|d&�t)|d'�r�g|j4D]}
|
j%�^q*|_4g|j4D]}
|
t5krO|
^qO}|r�tjd(|j|jd	j|�d	jt5��t|j�q�nt|jt	j6�s�tjd)|j|j�t|j�nt/t7|jjd*d+��}t	j8r@||jj9d,��j:�|_;n||j�j:�|_;t/|d|j;�|_<tjj=j||j<�|_>tjj=j|d-|j<�|_?t@j=jA|j>�s�t@jB|j>�ny|jC�|_DWnjtEk
rV}d.j|j|j|�}t|tF�r3|d/7}ntj|d0t�t|j�nXdS(2Nu{0}_saltenvtstricttrecursetkey_cbtval_cbcS@s
tj|�S(N(RR(R(ty((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt<lambda>�su
mountpointuiThe following parameter names are restricted to per-remote use only: %s. This is a bug, please report it.u, u�Invalid per-remote configuration for %s remote '%s'. If no per-remote parameters are being specified, there may be a trailing colon after the URL, which should be removed. Check the master configuration file.c3@s!|]}|�kr|VqdS(N((t.0R((tvalid_per_remote_params(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>su�{0} authentication parameter '{1}' (from remote '{2}') is only supported by the following provider(s): {3}. Current {0}_provider is '{4}'.ugitfsuLSee the GitFS Walkthrough in the Salt documentation for further information.uUInvalid {0} configuration parameter '{1}' in remote '{2}'. Valid parameters are: {3}.uM See the GitFS Walkthrough in the Salt documentation for further information.urootuuwinrepounameu/ii����u.giti����usaltenvurefu_urefspecsu{0}_refspecsu@The '%s' option has no default value in salt/config/__init__.py.utThe 'refspecs' option was not explicitly defined as a configurable parameter. Falling back to %s for %s remote '%s'.u
env_whitelistu
env_blacklistuNeonu�The gitfs_{0} config option (and {0} per-remote config option) have been renamed to gitfs_salt{0} (and salt{0}). Please update your configuration.usalt{0}uconfu	ref_typesuXThe following ref_types for %s remote '%s' are invalid: %s. The supported values are: %suZInvalid %s remote '%s'. Remotes must be strings, you may need to enclose the URL in quotesu	hash_typeumd5uutf-8ulinksu9Exception caught while initializing {0} remote '{1}': {2}u Perhaps git is not available.texc_info(u
env_whitelistu
env_blacklist(GtoptsR,tsalttutilstdatatrepack_dictlisttgetR+tTrueRRtglobal_saltenvtcopytdeepcopytconft	iteritemsturltstrip_protoR$tcriticaltjoinRR Rtdicttnexttitertidtget_urlR*R-tFalsetAUTH_PARAMStprovidertAUTH_PROVIDERStupdatetrsplittlowerRR"tPER_SALTENV_PARAMSthasattrtsetattrtadd_conf_overlayt_DEFAULT_MASTER_OPTStKeyErrortdebugtgetattrR
tversionst
warn_untiltdelattrt	ref_typestVALID_REF_TYPESRthashlibtPY3tencodet	hexdigestthashtcachedir_basenametpathtcachedirtlinkdirtostisdirtmakedirstinit_remotetnewR#t	GitPython(tselfR8tremotetper_remote_defaultstper_remote_onlytoverride_paramst
cache_rootR,tsaltenvtsaltenv_confR(tper_remote_collisionstper_remote_conftper_remote_errorstparamtmsgtsaltenv_ptrRR&tdefault_refspecsRtinvalid_ref_typest	hash_typeR)((R6s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt__init__�s&		!	&



		

	
 /
#$



 
%	$
c
@s'�fd�}d�jk}d�jk}t�}tjjj�j�r^|jd�nx�tjjj	|�D]�}|j
d�r�|d}n|jdd�\}}|d	kr�|r�|jd�}	|	d
r�|	d
n|	d}|||�qt|dkrt|rt|||�qtqtW|S(
u�
        Return the names of remote refs (stripped of the remote name) and tags
        which are map to the branches and tags.
        c@sb|�jkr&|j�j|�n8|�jkrE|jd�n�js^|j|�ndS(uC
            Add the appropriate saltenv(s) to the set
            ubaseN(tsaltenv_revmapRQtbasetaddtdisable_saltenv_mapping(tenv_settrname(Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
_check_ref�s	ubranchutagubaseurefs/iu/iuremotesiiutags(
R_tsetR9R:tstringutilstis_hexR�R�R;Rt
startswithR!t	partition(
RptrefsR�tuse_branchestuse_tagsRtreftrtypeR�tparted((Rps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_get_envs_from_ref_paths�s"	
uupdatecC@stjjj|j|d�S(Nu.lk(R9R:RgRGtgitdir(Rpt	lock_type((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_get_lock_file�sc@s&d�fd�}t|�|�dS(uV
        Programmatically determine config value based on the desired saltenv
        ubasec	@s��fd�}�jdkr5|t�d���S�jj|i���dkr.���fd�}||�}yK�j}|r�||kr�tjd||�j�j||�n|SWntk
r�nX|dkr��j	S�j
r!|dkrtjd�j�j|�n|S|p*|Sn��krH|���S|�jkr��j|kr|�j|��S|t�d���SdS(	Nc@s �dkr|jtj�S|S(Nurootu
mountpoint(urootu
mountpoint(trstripRjtsep(R((tname(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�sugitfsu_urefc@sM��kr��S|�jkrE��j|krE�j|�SdSdS(N(R?R
(ttgt_env(R�RwRp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_get_per_saltenvsu�The per-saltenv configuration has mapped the '%s' branch/tag to saltenv '%s' for %s remote '%s', but this remote has all_saltenvs set to '%s'. The per-saltenv mapping will be ignored in favor of '%s'.ubaseuWsaltenv mapping is diabled for %s remote '%s' and saltenv '%s' is not explicitly mapped(
R,R[RvR=tall_saltenvsR$RZRKtAttributeErrorR�R�R
R?(RpR�t	strip_sepR�tper_saltenv_reftall_saltenvs_ref(R�(RwRps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_getconf�s@
	

	
N(RV(tclsR�R�((R�s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRW�s9cC@sitjjj|j|j��jtj�}tjj	|�rC|St
jd|j�|j|j
�dS(u�
        Check if the relative root path exists in the checked-out copy of the
        remote. Return the full path to that relative root if it does exist,
        otherwise return None.
        u7Root path '%s' not present in %s remote '%s', skipping.N(R9R:RgRGRhtrootR�RjR�RkR$R%R,RKR
(Rptroot_dir((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
check_root3s	-cC@sgg}d}tjj�}d|d<d|d<tjtj|�dtjj	j
�dtjj|j
�d|dtjd	tj�}|j�d
}tjr�|jt�}n|jd
kr�tjd|j|j||�n�d}xOtjjj|d
�D]5}|j|�r|j|t|�j��qqW|rctjd|jdj |��n|S(uV
        Remove stale refs so that they are no longer seen as fileserver envs
        ugit remote prune origintCtLANGUAGEtLC_ALLt	close_fdstcwdtenvtstdouttstderriuOFailed to prune stale branches for %s remote '%s'. Output from '%s' follows:
%su * [pruned] u
u&%s pruned the following stale refs: %su, (!RjtenvironR@t
subprocesstPopentshlexR!R9R:tplatformt
is_windowsRgtdirnameR�tPIPEtSTDOUTtcommunicateRRbRt__salt_system_encoding__t
returncodeR$twarningR,RKt	itertoolsR�tappendtlenR"RZRG(Rptcleanedtcmd_strR�tcmdtoutputtmarkertline((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytclean_stale_refsEs8

		$c@s�jd|����fd�}g}g}ytj��Wn~tk
r�}|jtjkrhq�|jtjkr�ytj��Wq�tk
r�}|||�q�Xq�|||�n6Xdj	|�j
�j�}tj
|�|j|�||fS(u!
        Clear update.lk
        R�c@s6dj�j�|�}tj|�|j|�dS(Nu0Unable to remove update lock for {0} ({1}): {2} (R+RDR$RZR�(terrlistR)R|(t	lock_fileRp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
_add_errorvs
u%Removed {0} lock for {1} remote '{2}'(R�RjtremovetOSErrorterrnotENOENTtEISDIRtshutiltrmtreeR+R,RKR$RZR�(RpR�R�tsuccesstfailedR)R|((R�Rps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
clear_lockps,

c	C@stjj|jd�}tjjj�}|j|�sLt	j
d|�n�t}d}y|j|d�}Wn3tjjj
k
r�|j|�t}d}nXt	jd|j|j||j�||jkr|j|d|j�t	jd|j|j|j�t}ny"t|j|ddt��}Wn tjjjk
rWg}nXt|j�}t	jd	|j|j||�||kr�|j|d|j�t	jd
|j|j|�t}ny|jdd�}WnLtjjj
k
r|jd�d}n tjjjk
r1d}nXtj|j�j�}	t	jd
|j|j||	�||	kr�|jdd|	�t	jd|j|j|	�t}n|rtjjj|d��0}
|j |
�t	jd|j|j|�WdQXndS(u�
        For the config options which need to be maintained in the git config,
        ensure that the git config file is configured as desired.
        uconfigu&Failed to read from git config file %suremote "origin"uurlu6Current fetch URL for %s remote '%s': %s (desired: %s)u&Fetch URL for %s remote '%s' set to %sufetchtas_listu5Current refspecs for %s remote '%s': %s (desired: %s)u%Refspecs for %s remote '%s' set to %suhttpu	sslVerifyu;Current http.sslVerify for %s remote '%s': %s (desired: %s)u+http.sslVerify for %s remote '%s' set to %suwu/Config updates for %s remote '%s' written to %sN(!RjRgRGR�R9R:tconfigparsertGitConfigParsertreadR$R%RMR=tNoSectionErrortadd_sectionR>R
RZR,RKRDR�tsortedt
NoOptionErrortrefspecstset_multivarRRt
ssl_verifyRStfilestfopentwrite(Rpt
git_configRBtconf_changedtremote_sectionRDR�tdesired_refspecsR�tdesired_ssl_verifytfp_((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytenforce_git_config�sv

	
	
	
	
cC@s�y@|jdd��(tjd|j|j�|j�SWdQXWnWtk
r�}|jtjkr�tj	d|j|j|j
dd�|j�ntSXdS(u�
        Fetch the repo. If the local copy was updated, return True. If the
        local copy was already up-to-date, return False.

        This function requires that a _fetch() function be implemented in a
        sub-class.
        R�uupdateuFetching %s remote '%s'Nu1Update lock file is present for %s remote '%s', skipping. If this warning persists, it is possible that the update process was interrupted, but the lock could also have been manually set. Removing %s or running 'salt-run cache.clear_git_lock %s type=update' will allow updates to continue for this remote.(tgen_lockR$RZR,RKt_fetchRR�tEEXISTR�R�RM(RpR)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytfetch�s
c	C@s�ywtj|j|�tjtjBtjB�}tj|d��3tj|tj	j
jtj
tj����WdQXWn)ttfk
r�}|jtjkrVtj	jj|j|�d��L}y+ttj	j
j|j��j��}Wntk
r	d}nXWdQX|jd}|jd|�}|j|r�dj||||j|j�}	|r�|	dj|�7}	t|�s�|	d	7}	q�ntj |	�|r�|�ndS|r�t|�r�tj d
||j||�|r��ndS|rtj d||j||�n|j!�\}
}|
rC|j"ddd
|�S|rO�ndSq�dj||j|j|�|�}	tj#|	dt$�t%|j|	��nXdj||j|j�}	tj&|	�|	S(uO
        Place a lock file if (and only if) it does not already exist.
        uwbNuriu_global_lockR�uD{0} is enabled and {1} lockfile {2} is present for {3} remote '{4}'.u Process {0} obtained the locku� but this process is not running. The update may have been interrupted. If using multi-master with shared gitfs cache, the lock may have been obtained by another master.u Process %d has a %s %s lock (%s)uYProcess %d has a %s %s lock (%s), but this process is not running. Cleaning up lock file.uupdateR-u*Unable to set {0} lock for {1} ({2}): {3} R7u!Set {0} lock for {1} remote '{2}'('RjtopenR�tO_CREATtO_EXCLtO_WRONLYtfdopenR�R9R:R�tto_bytesRRtgetpidR�tIOErrorR�R�R�R�Rt
to_unicodetreadlineR�t
ValueErrorR,R8R+RKt
pid_existsR$R�R�t_lockR%R>RRZ(RpR�R-tfh_R)tfd_tpidtglobal_lock_keyR�R|R�tfail((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�sv8$+



			
cC@sng}g}y|jdd�}Wn#tk
rG}|j|j�nX|dk	rd|j|�n||fS(uG
        Place an lock file and report on the success/failure. This is an
        interface to be used by the fileserver runner, so it is hard-coded to
        perform an update lock. We aren't using the gen_lock()
        contextmanager here because the lock is meant to stay and not be
        automatically removed.
        R�uupdateN(R�RR�tstrerrorR
(RpR�R�tresultR)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytlockasig�?cc@s�t|tj�s0ttjdj|���nyt|�}Wntk
rYd}nX|dkrod}nt|tj	t
f�s�|dkr�d}n||kr�|}nt}z�tj�}x�t
r|y&|jd|dt
�t
}dVPWq�tttfk
rx}|s.tj�||krFt|j|j��qytjd||j|j|�tj|�q�q�Xq�WWd|r�|jd|�nXdS(u4
        Set and automatically clear a lock
        uInvalid lock_type '{0}'ig�?R�R-NuFA %s lock is already present for %s remote '%s', sleeping %f second(s)(RRRRR�tEINVALR+RR�t
integer_typestfloatRMttimeR>R�R�R�R�R$RZR,RKtsleepR�(RpR�ttimeoutt
poll_intervaltlock_sett
time_startR)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�tsD

				
cC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(tNotImplementedError(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRm�scC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytcheckout�scC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytdir_list�scC@s%tjjj|d|jd|j�S(uo
        Check if an environment is exposed by comparing it against a whitelist
        and blacklist.
        t	whitelistt	blacklist(R9R:R�tcheck_whitelist_blacklisttsaltenv_whitelisttsaltenv_blacklist(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytenv_is_exposed�s	cC@s
t��dS(ub
        Provider-specific code for fetching, must be implemented in a
        sub-class.
        N(R
(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��scC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytenvs�scC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt	file_list�scC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(RpRgR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt	find_file�scC@s�|jdkr�|jdkr�y|jSWntk
r<nX|jjd�pd|jjd�pdd}|dkrz|jStj|�S|jS(u0
        Resolve dynamically-set branch
        u
git_pillaru__env__u	pillarenvusaltenvubase(	R,tbranchR�R�R8R=R�RR(Rpttarget((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytget_checkout_target�s

cC@s�|j|�sdS|j|�}|dkr2dSx||jD]q}y"dj|�}t||�}Wn*tk
r�tjd|j	j
|�q<X||�}|dk	r<|Sq<WdS(uD
        Return a tree object for the specified environment
        uget_tree_from_{0}u!%s class is missing function '%s'N(RR
R�R_R+R[R�R$R%t	__class__t__name__(RpR�ttgt_reftref_typet	func_nametfunct	candidate((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytget_tree�s"
cC@sw|jdkrgy%|jjdd�\|_|_Wqstk
rc|jd|_|j|_qsXn|j|_dS(uW
        Examine self.id and assign self.url (and self.branch, for git_pillar)
        u
git_pillaruwinrepoiubranchN(u
git_pillaruwinrepo(R,RKR!R
RRDR�RB(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRLs%
cC@s4y|jSWn"tk
r/g|_y|jjd�}Wn'tk
rctjd|jj�n�Xx�t|d �D]q\}}y||dg}Wnt	k
r�g}nX|jj
tjj
j|j||d �|gf�quWy*|jjd|j|dggf�Wnt	k
r'nX|jSXdS(uq
        Return the expected result of an os.walk on the linkdir, based on the
        mountpoint value.
        u/u-%s class is missing a '_mountpoint' attributei����iiN(t
_linkdir_walkR�t_mountpointR!R$R%RRt	enumeratet
IndexErrorR�R9R:RgRGRitinsert(RptpartstidxRtdirs((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytlinkdir_walks0
	


	 *
cC@sdS(uX
        Only needed in pygit2, included in the base class for simplicty of use
        N((Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytsetup_callbacksBscC@s
d|_tS(uS
        Override this function in a sub-class to implement auth checking.
        N(R
tcredentialsR>(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytverify_authHs	cC@s
t��dS(uA
        This function must be overridden in a sub-class
        N(R
(Rptblobtdest((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
write_fileOs(#Rt
__module__t__doc__R�R�R�tclassmethodRWR�R�R�R�R�RMR�Rt
contextlibtcontextmanagerR�RmRRRR�RRRRR RLtpropertyR)R*R,R/(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR.�s:�	&@		+)	Z	Q	5											$		RocB@s}eZdZdd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�ZRS(u 
    Interface to GitPython
    ugitfscC@s5d|_tt|�j|||||||�dS(Nu	gitpython(ROtsuperRoR�(RpR8RqRrRsRtRuR,((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�Zs	c
C@s�|j�}y|jjd�j}Wntk
r>d}nXxTd|d|fd|d|ffD]*\}}y|jj|�j}Wntk
r�qhnX||kr�|j�SyL|jdd��4|jjj	|�t
jd|j|j
|�WdQXWn�tk
rw}|jtjkrQt|jdj|j|j
���q�t
jd	|j|j|j
�dSntk
r�qhnX|j�SWt
jd
||j|j
�dS(u
        Checkout the configured branch/tag. We catch an "Exception" class here
        instead of a specific exception class because the exceptions raised by
        GitPython when running these functions vary in different versions of
        GitPython.
        uHEADuorigin/utags/R�ucheckoutu)%s remote '%s' has been checked out to %sNu)Checkout lock exists for {0} remote '{1}'u?Error %d encountered obtaining checkout lock for %s remote '%s'uDFailed to checkout %s from %s remote '%s': remote ref does not exist(Rtrepot	rev_parsethexshaR#R
R�R�tgitRR$RZR,RKRR�R�R+R%(RpRthead_shatrev_parse_targettcheckout_reft
target_shaR)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRbsR

!



cC@s�t}tj|j�s9tjj|j�|_t}nSytj|j�|_Wn7tj	j
k
r�tjt
|j|j|j�|SXtjjj|jjd�|_|j�|S(u�
        Initialize/attach to a remote using GitPython. Return a boolean
        which will let the calling function know whether or not a new repo was
        initialized by this function.
        u.git(RMRjtlistdirRhR:tRepotinitR7R>R)tInvalidGitRepositoryErrorR$R%t
_INVALID_REPORDR,R9R:RgRGtworking_dirR�R�(RpRn((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRm�s	!
c@st�}�j��}|s"|S�j��rry|�j��}Wntk
r\|SX��fd�}n	d�}��fd�}xE|j�D]7}t|tj�r�|j|||j	���q�q�W�j
��r�|j�j
���n|S(uT
        Get list of directories for the target environment using GitPython
        c@stjj|�j���S(N(RjRgtrelpathR�(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�scS@s|S(N((Rg((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�sc@s%tjjj�j��|dt�S(Nt
use_posixpath(R9R:RgRGt
mountpointR>(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�s(R�R R�RYttraverseRR:tTreeR�RgRG(RpR�RttreeREtadd_mountpointR-((RpR�s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s$	
	#cC@s/g|jjD]}|j^q
}|j|�S(un
        Check the refs and return a list of the ones which can be used as salt
        environments.
        (R7R�RgR�(RpR(t	ref_paths((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s"c	C@s&|jjd}y|j�}Wntk
r?|j�}nXt}x�|D]�}|jdk	r�tjd|j	|j
|j|jjd |j
jd �t}qM|j|j|jfkrMtjd|j	|j|jkr�dnd|j
|j�t}qMqMW|j�}|s|r"tSdS(u�
        Fetch the repo. If the local copy was updated, return True. If the
        local copy was already up-to-date, return False.
        iu1%s has updated '%s' for remote '%s' from %s to %siu*%s has fetched new %s '%s' for remote '%s'utaguheadN(R7tremotesR�tAssertionErrorRMt
old_commitR
R$RZR,R�RKR9tcommitR>tflagstNEW_TAGtNEW_HEADR�(Rptorigint
fetch_resultstnew_objst	fetchinfoR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��s6


	

c@sUt�}i}�j��}|s.||fS�j��r�y|�j��}Wntk
rn||fSX��fd�}n	d�}��fd�}x�|j�D]�}t|tj�s�q�n|||j��}|j	|�t
j|j�r�t
j�}	|j|	�|	jd�|	j�}
|	j�|
||<q�q�W||fS(uJ
        Get file list for the target environment using GitPython
        c@stjj|�j���S(N(RjRgRER�(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4scS@s|S(N((Rg((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4sc@s%tjjj�j��|dt�S(NRF(R9R:RgRGRGR>(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4si(R�R R�RYRHRR:tBlobRgR�tstattS_ISLNKtmodeRtStringIOtstream_datatseekR�tclose(RpR�R�tsymlinksRJRERKt	file_blobt	file_pathtstreamtlink_tgt((RpR�s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRs4	

	



c	C@sA|j|�}|sdSd}d}x�tr|d7}|tkrNd}Pny�||}tj|j�r�tj�}|j	|�|j
d�|j�}|j�t
jjjtjj|�|dt�}n"|}t|tj�r�d}nPWq(tk
rd}Pq(Xq(Wt|tj�r=||j|jfSdS(uF
        Find the specified file in the specified environment
        iiRFN(NNN(NNN(R R
R>tSYMLINK_RECURSE_DEPTHRYRZR[RR\R]R^R�R_R9R:RgRGRjR�RR:RIRYRXR9(	RpRgR�RJR-tdepthRaRcRd((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR&s<	




!	
	cC@s?y&tj|jdj|��jjSWntk
r:dSXdS(uh
        Return a git.Tree object matching a head ref fetched into
        refs/remotes/origin/
        urefs/remotes/origin/{0}N(R:tRemoteReferenceR7R+RPRJR�R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytget_tree_from_branchQs
cC@s?y&tj|jdj|��jjSWntk
r:dSXdS(uU
        Return a git.Tree object matching a tag ref fetched into refs/tags/
        u
refs/tags/{0}N(R:tTagReferenceR7R+RPRJR�R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytget_tree_from_tag]s
cC@s<y|jj|�jSWntjjtfk
r7dSXdS(u9
        Return a git.Tree object matching a SHA
        N(R7R8RJtgitdbR)tODBErrorR�R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytget_tree_from_shahscC@s2tjjj|d��}|j|�WdQXdS(uO
        Using the blob object, write the file to the destination path
        uwb+N(R9R:R�R�R](RpR-R.R�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR/qs(RR0R1R�RRmRRR�RRRhRjRmR/(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRoVs	C				&	"	+				tPygit2cB@s�eZdZdd�Zd�Zd�Zdd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZRS(u
    Interface to Pygit2
    ugitfscC@s5d|_tt|�j|||||||�dS(Nupygit2(ROR6RnR�(RpR8RqRrRsRtRuR,((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�}s	cC@s-y|j�SWntk
r(|j�SXdS(uY
        Compatibility function for pygit2.Reference objects. Older versions of
        pygit2 use .get_object() to return the object to which the reference
        points, while newer versions use .peel(). In pygit2 0.27.4,
        .get_object() was removed. This function will try .peel() first and
        fall back to .get_object().
        N(tpeelR�t
get_object(Rptobj((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRo�s
c@s��j�}d|}d|}d|}y�jjd�}Wn+tk
rmtjd�j�j�dSXy�j	|�j
}WnAtk
r�tjd�j�j�dStk
r�d}nX�jj
�}t��fd�}yx||krs�j	�jj|��j�||kr;�jj|��ny"�j	�jj|��j
}	Wn4tk
r�tjd|�j�jd	t�dSX||	kri|j}
t|
tj�rP|
|krP|
|krP|
jd�d
}|stjd|
�j�j�dSd|}||kr+|}n�jj|
�jj|�j�n||dt�sidSn�j�S||krc�jj|�}
t|
tj�s�tjd
|�qcy|
jj
}WnUtk
ry
|
j
}Wqtk
rtjd|�j�jd	t�dSXnXtjd||�||krV||dt�sVdSn�j�SnWnLtk
rz�n9tk
r�}tjd|�j�j|d	t�dSXtjd|�j�j�dS(u4
        Checkout the configured branch/tag
        urefs/heads/urefs/remotes/origin/u
refs/tags/uHEADu"HEAD not present in %s remote '%s'u,Unable to get SHA of HEAD for %s remote '%s'c@s�yP�jdd��4�jj|�|rE�jj�tj�nWdQXtSWnktk
r�}|jtj	kr�t|jdj
�j�j���q�t
jd|j�j�j�nXtS(uP
            DRY function for checking out either a branch or a tag
            R�ucheckoutNu)Checkout lock exists for {0} remote '{1}'u?Error %d encountered obtaining checkout lock for %s remote '%s'(R�R7RtresetRtGIT_RESET_HARDR>RR�R�R+R,RKR$R%RM(R=RR)(toidRp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_perform_checkout�s$u5pygit2 was unable to get SHA for %s in %s remote '%s'R7i����uMpygit2 was unable to resolve branch name from HEAD ref '%s' in %s remote '%s'Ru.%s does not correspond to pygit2.Commit objectuTUnable to resolve %s from %s remote '%s' to either an annotated or non-annotated taguSHA of tag %s: %su-Failed to checkout %s from %s remote '%s': %suDFailed to checkout %s from %s remote '%s': remote ref does not existN(RR7tlookup_referenceRYR$R�R,RKR
RothexR�R%tlistall_referencesR>tcreate_referenceRRRRR�R�trevparse_singleRtCommitRZRMRR#(RpRt	local_reft
remote_refttag_reft
local_headR;R�RuR>thead_reftbranch_nametremote_headttag_objttag_shaR)((RtRps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s�






 "

	
		




	
cC@saytjrgSWntk
r$nX|jdk	rNtjdt|j�gSt	t
|�j�S(uX
        Clean stale local refs so they don't appear as fileserver environments
        u�The installed version of pygit2 (%s) does not support detecting stale refs for authenticated remotes, saltenvs will not reflect branches/tags removed from remote '%s'N(RtGIT_FETCH_PRUNER�R+R
R$RZtPYGIT2_VERSIONRKR6RnR�(Rpt
local_refs((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�Js	

cC@s)tjjd�}|tjjtj<t}tj|j	�s[tj
|j	�|_t}nMytj
|j	�|_Wn1tk
r�tjt|j	|j|j�|SXtjjj|jjd�|_|j�tjj|jd�}tjj|�r%ttd�kr%|jjj|�n|S(u�
        Initialize/attach to a remote using pygit2. Return a boolean which
        will let the calling function know whether or not a new repo was
        initialized by this function.
        u~u.gituconfigu0.28.0(RjRgt
expanduserRtsettingstsearch_pathtGIT_CONFIG_LEVEL_GLOBALRMR?Rhtinit_repositoryR7R>t
RepositoryRYR$R%RCRDR,R9R:RGtworkdirR�R�texistsR�t
_LooseVersiontconfigtadd_file(RpthomeRnR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRm_s"	
!
$c	@sI��fd��t�}�j��}|s4|S�j��r�y'|�j��j}�j|}Wntk
r~|SXt|tj�s�|S��fd�}n	d�}g}t	|�r��||�j���n��fd�}x'|D]}|j
|||���q�W�j��rE|j
�j���n|S(uS
        Get a list of directories for the target environment using pygit2
        c	@s�x�t|�D]�}|j�jkr+q
n�j|j}t|tj�sSq
n|jtjj	j
||jdt��t
|�r
�||tjj	j
||jdt��q
q
WdS(u�
            Traverse through a pygit2 Tree object recursively, accumulating all
            the empty directories within it in the "blobs" list
            RFN(RJRtR7RRRIR�R9R:RgRGR�R>R�(RJtblobstprefixtentryR-(t	_traverseRp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��s"c@stjj|�j���S(N(RjRgRER�(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�scS@s|S(N((Rg((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�sc@s%tjjj�j��|dt�S(NRF(R9R:RgRGRGR>(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�s(R�R R�RtR7RYRRRIR�R�RG(	RpR�RRJRtRER�RKR-((R�RpR�s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR~s0	
	
cC@s|jj�}|j|�S(un
        Check the refs and return a list of the ones which can be used as salt
        environments.
        (R7RxR�(RpRL((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�sc
C@s|jjd}|jj�}i}|jdk	rD|j|d<n|jdk	rb|j|_nytj|d<Wntk
r�nXy|j	|�}Wn�t
k
rU}t|�j�}d|krt
|jtj�rtjd|j|jdt�nPd|kr/tjd|j|jdt�n"tjd	|j|j|dt�tSXy|d
}Wn ttfk
r�|j}nX|dkr�tjd|j||j�ntjd|j|j�|jj�}|jd
|�}	|s||ks|	rtSdS(u�
        Fetch the repo. If the local copy was updated, return True. If the
        local copy was already up-to-date, return False.
        iu	callbacksupruneuunsupported url protocolu�Unable to fetch SSH-based %s remote '%s'. You may need to add ssh:// to the repo string or libgit2 must be compiled with libssh2 to support SSH authentication.R7u+authentication required but no callback setuH%s remote '%s' requires authentication, but no authentication configuredu*Error occurred fetching %s remote '%s': %sureceived_objectsu&%s received %s objects for remote '%s'u%s remote '%s' is up-to-dateR�N(R7RMRxtremotecallbacksR
R+RR�R�R�tGitErrorR	RSRtKeypairR$R%R,RKR>RMRtreceived_objectsRZR�(
RpRTtrefs_pretfetch_kwargsRUR)texc_strR�t	refs_postR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��sX



c@s���fd��t�}i}�j��}|s@||fS�j��r�y'|�j��j}�j|}Wntk
r�||fSXt|tj�s�||fS��fd�}n	d�}i}t	|�r��||�j���n��fd�}x3|j
dg�D]}	|j|||	���qWx?tj
|j
di��D]"\}	}
|
||||	��<q]W||fS(uG
        Get file list for the target environment using pygit2
        c	@sxt|�D]	}|j�jkr+q
n�j|j}t|tj�r�tjjj	||j
dt�}|jdg�j
|�tj||j
j�r�j||j
jj}||jdi�|<qq
t|tj�r
�||tjjj	||j
dt��q
q
WdS(u�
            Traverse through a pygit2 Tree object recursively, accumulating all
            the file paths and symlink info in the "blobs" dict
            RFufilesusymlinksN(RJRtR7RRRXR9R:RgRGR�R>t
setdefaultR�RYRZtfilemodeR;RI(RJR�R�R�Rqt	repo_pathRd(R�Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��sc@stjj|�j���S(N(RjRgRER�(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4%scS@s|S(N((Rg((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4'sc@s%tjjj�j��|dt�S(NRF(R9R:RgRGRGR>(Rg(RpR�(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4+sufilesusymlinks(R�R R�RtR7RYRRRIR�R=R�RRC(RpR�R�R`RJRtRER�RKR�Rd((R�RpR�s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s2	


	(c	C@s+|j|�}|sdSd}d}d}x�tr|d7}|tkrTd}Pny�||}|j}tj|�r�|j|jj	}t
jjj
tjj|�|dt�}n,|j|j}t|tj�r�d}nPWq.tk
rd}Pq.Xq.Wt|tj�r'||j|fSdS(uF
        Find the specified file in the specified environment
        iiRFN(NNN(NNN(R R
R>ReR�RYRZR7RtR;R9R:RgRGRjR�RRRIRYRXRw(	RpRgR�RJR-R[RfR�Rd((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR3s8	

	!	
	cC@sBy)|j|jjdj|���jSWntk
r=dSXdS(uk
        Return a pygit2.Tree object matching a head ref fetched into
        refs/remotes/origin/
        urefs/remotes/origin/{0}N(RoR7RvR+RJRYR
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRh[s

cC@sBy)|j|jjdj|���jSWntk
r=dSXdS(uX
        Return a pygit2.Tree object matching a tag ref fetched into refs/tags/
        u
refs/tags/{0}N(RoR7RvR+RJRYR
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRjfs

cC@s<y|jj|�jSWnttttfk
r7dSXdS(u<
        Return a pygit2.Tree object matching a SHA
        N(R7RzRJRYRR�R�R
(RpR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRmpscC@swttd�krHtjd|j�|_|jssd�|j_qsn+d|_|jsst	j
djt��ndS(u8
        Assign attributes for pygit2 callbacks
        u0.23.2R+c_@stS(N(R>(targstkwargs((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR4�su�pygit2 does not support disabling the SSL certificate check in versions prior to 0.23.2 (installed: {0}). Fetches for self-signed certificates will fail.N(R�R�RtRemoteCallbacksR+R�R�tcertificate_checkR
twarningstwarnR+(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR*ys				c@sNd�_tjj�j�r"tSt�fd�tD��sBtS�fd�}�fd�}�jj	d�\}}}|s�d}�j}n|j
�}|dkr�tSd|kr$d}|jd
�d}||kr	tj
d�j�j�t�j�n|�_t�fd
�|D��r�gdD]}t�|d�^q5}	xzddfD]l\}
}|	|
}|dk	r`y&tjj|�s�|||�nWq�tk
r�|||�q�Xq`q`Wtj|	��_tSg|D]$}tt�|d��s�|^q�}
||
�n&d|kr!d}t�fd�|D��}t�fd�|D��}|rytS|r�|dkr��jr�tj
d�j�j�j�t�j�ntj�j�j��_tSg|D]$}tt�|d��s�|^q�}
||
�n)tj
d�j�j|�t�j�dS(u�
        Check the username and password/keypair info for validity. If valid,
        set a 'credentials' attribute consisting of the appropriate Pygit2
        credentials object. Return False if a required auth param is not
        present. Return True if the required auth parameters are present (or
        auth is not configured), otherwise failhard if there is a problem with
        authenticaion.
        c3@s!|]}t�|d�VqdS(N(R[R
(R5R((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�sc@s6tjd�j�jdj|��t�j�dS(uU
            Helper function to log errors about missing auth parameters
            uPIncomplete authentication information for %s remote '%s'. Missing parameters: %su, N(R$RFR,RKRGR-(tmissing(Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_incomplete_auth�sc@s0tjd||�j�j�t�j�dS(uN
            Helper function to log errors about missing key file
            uSSH %s (%s) for %s remote '%s' could not be found, path may be incorrect. Note that it may be necessary to clear git_pillar locks to proceed once this is resolved and the master has been started back up. A warning will be logged if this is the case, with instructions.N(R$RFR,RKR-(tkey_typeRg(Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_key_does_not_exist�su://usshugitufileupubkeyuprivkeyu@iuJKeypair specified for %s remote '%s', but remote URL is missing a usernamec3@s'|]}tt�|d��VqdS(N(RR[R
(R5R((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�suuseru
passphraseiiuhttpupasswordc3@s'|]}tt�|d��VqdS(N(RR[R
(R5R((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�sc3@s'|]}tt�|d��VqdS(N(RR[R
(R5R((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�suInvalid configuration for %s remote '%s'. Authentication is disabled by default on http remotes. Either set %s_insecure_auth to True in the master configuration file, set a per-remote config option named 'insecure_auth' to True, or use https or ssh-based authentication.uEInvalid configuration for %s remote '%s'. Unsupported transport '%s'.N(ugitufile(upubkeyuprivkey(uuserupubkeyuprivkeyu
passphrase(iupubkey(iuprivkey(uuserupassword(R
R+RjRgtisabsRDR>tanyRNR�RSR!R$RFR,RKR-tusertallR[tisfileRRR�Rt
insecure_authtUserPasstpassword(RpR�R�t	transportt_taddresstrequired_paramsR�R(tkeypair_paramsR'R�tkey_pathtmissing_authtpassword_oktno_password_auth((Rps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR,�s|			"


$

$
cC@s5tjjj|d��}|j|j�WdQXdS(uO
        Using the blob object, write the file to the destination path
        uwb+N(R9R:R�R�R�R;(RpR-R.R�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR/sN(RR0R1R�RoRR
R�RmRRR�RRRhRjRmR*R,R/(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRnys"	
	�		3		A	9	(		
				{u	gitpythontGitBasecB@s�eZdZddeedded�Zdeed�Zd�Z	d�Z
ddd�Zdd�Zdd�Z
dd	�Zd
�Zd�Zed�Zed
�Zd�Zd�ZRS(u)
    Base class for gitfs/git_pillar
    c		C@s)||_|dk	r|nt|_|j�|dk	rM||_|_nCtjj	j
|jd|j�|_tjj	j
|jd�|_tjj	j
|jd�|_tjj	j
|jd�|_
tjj	j
|jdd|j�|_|r%|j|dk	r|ng|||�ndS(u
        IMPORTANT: If specifying a cache_root, understand that this is also
        where the remotes will be cloned. A non-default cache_root is only
        really designed right now for winrepo, as its repos need to be checked
        out into the winrepo locations and not within the cachedir.

        As of the 2018.3 release cycle, the classes used to interface with
        Pygit2 and GitPython can be overridden by passing the git_providers
        argument when spawning a class instance. This allows for one to write
        classes which inherit from salt.utils.gitfs.Pygit2 or
        salt.utils.gitfs.GitPython, and then direct one of the GitBase
        subclasses (GitFS, GitPillar, WinRepo) to use the custom class. For
        example:

        .. code-block:: Python

            import salt.utils.gitfs
            from salt.fileserver.gitfs import PER_REMOTE_OVERRIDES, PER_REMOTE_ONLY

            class CustomPygit2(salt.utils.gitfs.Pygit2):
                def fetch_remotes(self):
                    ...
                    Alternate fetch behavior here
                    ...

            git_providers = {
                'pygit2': CustomPygit2,
                'gitpython': salt.utils.gitfs.GitPython,
            }

            gitfs = salt.utils.gitfs.GitFS(
                __opts__,
                __opts__['gitfs_remotes'],
                per_remote_overrides=PER_REMOTE_OVERRIDES,
                per_remote_only=PER_REMOTE_ONLY,
                git_providers=git_providers)

            gitfs.fetch_remotes()
        ucachediruremotesuenvs.puhashu
file_listsN(R8R
t
GIT_PROVIDERSt
git_providerstverify_providerRutremote_rootR9R:RgRGR,t	env_cachet
hash_cachedirtfile_list_cachedirtinit_remotes(	RpR8RMtper_remote_overridesRstglobal_onlyR�RuR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s&*		
c	C@s8tj|�}gtD]7}|jdj|j|�rdj|j|�^q}|jtkro|t7}nc|r�dj|j|jdjt��}|jdkr�|d7}nt	j
|�t|j�ni}	t|�}
|
j
t|��xl|
D]d}dj|j|�}||jkrHt	j
d|�t|j�nt||j|�|	|<q�Wg|_x�|D]�}
|j|j|j|
|	|||j|j�}t|d�rv|j�|j�|jdd	kr�|jr�|j�ni|_x�tj|j�D]�\}}d
|kr|d
}|jj|g�j|�|dkr�|j|jd
�||jkr�t	jd|j|j |j�||_q�q�qqWg}x'tj!|j�D]}|j"|�q�Wx[tj|j#�D]G\}}||kr�d
|kr�|jj|d
g�j|�q�q�W|jj|�qvqvWi}x0|jD]%}|j|j$g�j|j �qlWg|D]"}t%||�d
kr�|^q�}|rxA|D]6}t	j
d|jdj||��t|j�q�Wnt&d�|jD��r4|j'�ndS(u$
        Initialize remotes
        u{0}_{1}u�{0} authentication was configured, but the '{1}' {0}_provider does not support authentication. The providers for which authentication is supported in {0} are: {2}.u, ugitfsuM See the GitFS Walkthrough in the Salt documentation for further information.uNKey '%s' not present in global configuration. This is a bug, please report it.urepou__roleuminionurefubaseu�The 'base' environment has been defined in the 'saltenv' param for %s remote %s and will override the branch/tag specified by %s_base (or a per-remote 'base' parameter).iuqThe following %s remotes have conflicting cachedirs: %s. Resolve this using a per-remote parameter called 'name'.cs@s|]}|jVqdS(N(Rn(R5R(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�sN((R@RARNR8R+R,RORPRGR$RFR-R�RQR*RMR�RuRUR,R*RnR�R�RRCRvR�R�tpopR�R�RKt
itervaluestextendR?RhR�R�twrite_remote_map(RpRMR�RsR�RtR(tglobal_auth_paramsR|Rrt
global_valuesR{RRqtrepo_objRvRwR�tall_envst	env_namesRBtcachedir_mapR7t
collisionsR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�\s�

7



	




	
		#/
cC@s�ytj|j�}Wntk
r/g}nXx9|jD].}y|j|j�Wq:tk
rgq:Xq:Wg}x]|D]U}|dkr�qyntj	j
j|j|�}tj
j|�ry|j
|�qyqyWg}|rUxt|D]i}ytj|�Wn9tk
r7}tjd|j||�|j
|�q�Xtjd|j|�q�Wnx|D]}	|j|	�q\Wt|�}
|
r�|j�n|
S(uK
        Remove cache directories for remotes no longer configured
        uhashurefsu.Unable to remove old %s remote cachedir %s: %su%s removed old cachedir %s(uhashurefs(RjR?RuR�RMR�RfR�R9R:RgRGRkR�R�R�R$R%R,RZRR�(Rptcachedir_lsR7t	to_removeRRgR�trdirR)tfdirR((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytclear_old_remotes�sB






cC@s|g}xo|j|jfD][}tjj|�rytj|�Wqttk
rp}|jdj	||��qtXqqW|S(u(
        Completely clear cache
        uUnable to delete {0}: {1}(
RuR�RjRgR�R�R�R�R�R+(RpterrorsR�R)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytclear_cache	suupdatecC@s�g}g}x�|jD]�}|r|ytj|j|�s@wnWq|tk
rxtj|jtj|��syqqyq|Xn|jd|�\}}|j|�|j|�qW||fS(u1
        Clear update.lk for all remotes
        R�(RMtfnmatchRDRRRR�R�(RpRqR�tclearedR�R7R�R�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�	s



c	C@s�|dkrg}n(t|t�s=tjd|�g}nt}x�|jD]�}t|dd�}|s�|j|f|krMy|j	�r�t
}nWq�tk
r�}tjd|j|j|dt
�q�XqMqMW|S(u�
        Fetch all remotes and return a boolean to let the calling function know
        whether or not any remotes were updated in the process of fetching
        uLInvalid 'remotes' argument (%s) for fetch_remotes. Must be a list of stringsunameu2Exception caught while fetching %s remote '%s': %sR7N(
R
RR R$R%RMRMR[RKR�R>R#R,(RpRMtchangedR7R�R)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
fetch_remotes'	s(		
cC@s�g}g}x�|jD]�}|r|ytj|j|�s@wnWq|tk
rxtj|jtj|��syqqyq|Xn|j�\}}|j|�|j|�qW||fS(u$
        Place an update.lk
        (RMR�RDRRRRR�(RpRqtlockedR�R7R�R�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRJ	s



c	
C@s�itd6dd6}|j�|d<|jd|�rCt|d<n|jddk}|dtks|tjj|j�r�tjj	|j�}tjj
|�s�tj|�nt}n|r9|jdt�}t
jj|j�}t
jjj|jd��0}|j|j|��tjd	|j�Wd
QXn|jjdt�r�t
jjjd|jd
|jdd|jdt�}|j|tddgdd��nyt
jj|j|j�Wnt t!fk
r�nXd
S(uE
        .. versionchanged:: 2018.3.0
            The remotes argument was added. This being a list of remote URLs,
            it will only update matching remotes. This actually matches on
            repo.id

        Execute a git fetch on all of the repos and perform maintenance on the
        fileserver cache.
        uchangedugitfsubackendRMu__roleuminiontignore_cacheuwb+uWrote env cache data to %sNufileserver_eventsumasterusock_diru	transportR8tlistenuupdateR�u
fileserver("RMR�R�R>R8RjRgR�R�R�R�RlRR9tpayloadtSerialR:R�R�R�tdumpsR$ttraceR=teventt	get_eventt
fire_eventR
t
fileservertreap_fileserver_cache_dirR�RR�R�(	RpRMR;trefresh_env_cachetenv_cachedirtnew_envstserialR�R�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRQ`	sB


&	

			cC@sd�|jD�S(ut
        Returns a dictionary mapping remote IDs to their intervals, designed to
        be used for variable update intervals in salt.master.FileserverUpdate.

        A remote's ID is defined here as a tuple of the GitPython/Pygit2
        object's "id" and "name" attributes, with None being assumed as the
        "name" value if the attribute is not present.
        cS@s1i|]'}|j|jt|dd�f�qS(unameN(tupdate_intervalRKR[R
(R5R7((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys
<dictcomp>�	s	(RM(Rp((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytupdate_intervals�	s	cC@s�dj|j�|jkr:|jdj|j�|_n(|jjdj|j��}|s�|jdt�r|d|_qb|jdt�rbd|_qbn�y|j�}Wn&t	k
r�t
j|�j�}nX||jkrt
jd|j|dj|j��t|j�nH|dkr>|j�r>d|_n$|dkrb|j�rbd|_nt|d�s�t
jd	|j�t|j�nd
S(u1
        Determine which provider to use
        uverified_{0}_provideru{0}_providertquietupygit2u	gitpythonu/Invalid %s_provider '%s'. Valid choices are: %su, uprovideru,No suitable %s provider module is installed.N(R+R,R8ROR=t
verify_pygit2R>tverify_gitpythonRSR�RRR�R$RFRGR-RU(Rptdesired_provider((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��	s6

c@s�fd�}ts<|s8tjd�j�|�ntSd�jkrOtSg}ttkr�|jdj�jtt��nt	j
jjd�s�|jdj�j��n|r�x|D]}tj|�q�W|s�|�ntSd�j
dj�j�<tjd�j�tS(	uX
        Check if GitPython is available and at a compatible version (>= 0.3.0)
        c@s5tr1d�jkr1tjt�j�j�ndS(Nupygit2(R�R�R$R%t_RECOMMEND_PYGIT2R,((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
_recommend�	suA%s is configured but could not be loaded, is GitPython installed?u	gitpythonuW{0} is configured, but the GitPython version is earlier than {1}. Version {2} detected.ugituQThe git command line utility is required when using the 'gitpython' {0}_provider.uverified_{0}_providerugitpython %s_provider enabled(tGITPYTHON_VERSIONR$R%R,RMR�tGITPYTHON_MINVERR�R+R9R:RgtwhichR8RZR>(RpR�R�R�R%((Rps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��	s<




c@s^�fd�}ts<|s8tjd�j�|�ntSd�jkrOtSg}ttkr�|jdj�jtt��nt	t
kr�|jdj�jt
t	��nttdt�r�t
jjjd�r�|jdj�j��n|r.x|D]}tj|�qW|s*|�ntSd�jd	j�j�<tjd
�j�tS(u�
        Check if pygit2/libgit2 are available and at a compatible version.
        Pygit2 must be at least 0.20.3 and libgit2 must be at least 0.20.0.
        c@s5tr1d�jkr1tjt�j�j�ndS(Nu	gitpython(R�R�R$R%t_RECOMMEND_GITPYTHONR,((Rp(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��	suK%s is configured but could not be loaded, are pygit2 and libgit2 installed?upygit2uT{0} is configured, but the pygit2 version is earlier than {1}. Version {2} detected.uU{0} is configured, but the libgit2 version is earlier than {1}. Version {2} detected.uGIT_FETCH_PRUNEugituNThe git command line utility is required when using the 'pygit2' {0}_provider.uverified_{0}_providerupygit2 %s_provider enabled(R�R$R%R,RMR�t
PYGIT2_MINVERR�R+tLIBGIT2_VERSIONtLIBGIT2_MINVERR[RR9R:RgR�R8RZR>(RpR�R�R�R%((Rps4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��	sJ





c
C@s�tjjj|jd�}y�tjjj|d��z}tj�j	d�}|j
dj|j|��x?|j
D]4}|j
tjjjdj|j|j���qtWWdQXWntk
r�nXtjd|j|�dS(u*
        Write the remote_map.txt
        uremote_map.txtuw+u%d %b %Y %H:%M:%S.%fu# {0}_remote map as of {1}
u
{0} = {1}
NuWrote new %s remote map to %s(R9R:RgRGRuR�R�RtnowtstrftimeR�R+R,RMR�tto_strRfRKR�R$tinfo(Rpt
remote_mapR�t	timestampR7((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�2
s"

cC@s�tj�}x�tj�|dkr�y|j�SWqtk
r�}|jtjkrjtjd�qq�tjd|j|j|j	|dt
�PqXqWtjd|j|j	|j�dS(uj
        Common code for git_pillar/winrepo to handle locking and checking out
        of a repo.
        ig�������?uIError %d encountered while obtaining checkout lock for %s remote '%s': %sR7u�Timed out waiting for checkout lock to be released for %s remote '%s'. If this error persists, run 'salt-run cache.clear_git_lock %s type=checkout' to clear it.N(RRRR�R�RR$R%R,RKR>R
(RpR7R	R)((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytdo_checkoutO
s(
	N(((RR0R1R
tPER_REMOTE_ONLYtGLOBAL_ONLYR>R�R�R�R�R�R�RRQR�R�RMR�R�R�R(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s&={	)	#8		'.9	tGitFScB@s�eZdZdZej�Zddedde	d�Z
dedde	d�Zd�Ze
d�Zdd�Zd�Zd	�Zd
�Zd�Zd�Zd
�ZRS(u>
    Functionality specific to the git fileserver backend
    ugitfsc
C@s�|rtjjj�nd	}|s4||jkr�tj|�}	tt	|	�j
||d	k	rg|ngd|d|d|d	k	r�|ntd|d|�|s�tj
d�n#tj
dtj��|	|j|<|	Stj
dtj��|j|S(
u�
        If we are not initializing remotes (such as in cases where we just want
        to load the config so that we can run clear_cache), then just return a
        new __init__'ed object. Otherwise, check the instance map and re-use an
        instance if one exists for the current process. Weak references are
        used to ensure that we garbage collect instances for threads which have
        exited.
        R�RsR�RuR�u/Created gitfs object with uninitialized remotesu#Created gitfs object for process %su$Re-using gitfs object for process %sN(ttornadotiolooptIOLooptcurrentR
tinstance_maptobjectt__new__R6RR�R�R$RZRjR�(
R�R8RMR�RsR�RuR�tio_loopRq((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRx
s&
cC@sdS(N((RpR8RMR�RsR�RuR�((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR��
scC@s|j|d�S(u@
        Return a list of all directories on the master
        udirs(t_file_lists(Rptload((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�
scC@s�|s4tjj|j|j�}|dk	r4|Snt�}xv|jD]k}|j�}x't	j
|j�D]}|j|�qlW|jg|D]}|j
|�r�|^q��qGWt|�S(uH
        Return a list of refs that can be used as environments
        N(R9R�tcheck_env_cacheR8R�R
R�RMRRR�R�RQRR�(RpR�tcache_matchRR7t	repo_envstenv_listR(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�
s		3ubasecK@sidd6dd6}tjj|�sNtjjj|�rR||j�krR|Stjjj|j	d||�}tjjj|j
|dj|��}tjjj|j
|dj|��}tjjj|j
|dj|��}tjj|�}	tjj|�}
tjj
|	�s`ytj|	�Wq`tk
r\tj|	�tj|	�q`Xntjj
|
�s�ytj|
�Wq�tk
r�tj|
�tj|
�q�Xnxd|jD]Y}|j|�r�|j|j|�tj�r�q�n|t|j|��jtj�}|j|�rQtjjj|j|�|�}n|j||�\}
}}|
d
kr~q�nd�}tjj||�ymtjjj|d	��O}tjjj|j��}||kr||d<||d<|||�SWd
QXWn.t k
r7}|j!t!j"kr8|�q8nXtjjj|d��Wd
QXx<t#j#|�D]+}ytj|�Wqgt$k
r�qgXqgW|j%|
|�tjjj|d��}|j&|�Wd
QXytj|�Wntk
r�nX||d<||d<|||�SW|S(
u�
        Find the first file to match the path and ref, read the file out of git
        and send the path to the newly cached file
        uupathurelurefsu
{0}.hash.*u{0}.hash.blob_sha1u{0}.lkcS@s |dk	r|g|d<n|S(u!
                Add a the mode to the return dict. In other fileserver backends
                we stat the file to get its mode, and add the stat result
                (passed through list() for better serialization) to the 'stat'
                key in the return dict. However, since we aren't using the
                stat result for anything but the mode at this time, we can
                avoid unnecessary work by just manually creating the list and
                not running an os.stat() on all files in the repo.
                ustatN(R
(tfndR[((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt_add_file_stat�
s
urNuwuw+('RjRgR�R9R:R�R�RRGRuR�R+R�RkRlR�R�RMRGR�R�R�tlstripR�RR
R�t	wait_lockR�R�R�R�R�R�R�tglobR#R/R�(RpRgR�R�RR.thashes_globtblobshadesttlk_fntdestdirthashdirR7R�R-tblob_hexshat	blob_modeRR�tshaR)tfilename((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�
s�

(!



 %$	






c	
@s�d�kr�jd�nidd6dd6}tdddg�}t�fd�|D��s�tjd	d
j|j����|S|ds�|S|d|d<�jdd�}t	j
j|d�}tj
jj|d
���}|j�d�|j|jd�}|rDtjrDtj
jj|�rD|jt�}n|ru|rutj
jj||�}||d<n||d<WdQX|S(uG
        Return a chunk from a file based on the data received
        uenvuudataudestupathulocusaltenvc3@s|]}|�kVqdS(N((R5R((R(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>+su<Not all of the required keys present in payload. Missing: %su, urelugzipurbufile_buffer_sizeN(R�R�R�R$RZRGt
differenceR=R
RjRgtnormpathR9R:R�R�R^R�R8RRbt	is_binaryRR�t	gzip_utiltcompress(	RpRRRtrequired_load_keystgziptfpathR�R;((Rs4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt
serve_file s2


%
c	@s�d�kr�jd�nt�fd�d
D��s<dSi|jdd6}|d}|d}tjjj|j�ddj	||jd��}y9tjj
j|d	��}|j�|d
<WdQX|SWn.t
k
r}|jtjkr|�qnXytjtjj|��Wn.tk
rP}|jtjkrQ|�qQnXtjjj||jd�|d
<tjj
j|d��}|j|d
�WdQX|S(uT
        Return a file hash, the hash type is set in the master config file
        uenvc3@s|]}|�kVqdS(N((R5R((R(s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>Isupathusaltenvuu	hash_typeurelu{0}.hash.{1}urbuhsumNuw+(upathusaltenv(uN(R�R�R
R8R9R:RgRGR�R+R�R�R�R�R�R�RjRlR�R�R�t	hashutilstget_hashR�(	RpRRRRERgthashdestR�R)((Rs4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt	file_hashAs6

	

#cC@sUd|kr|jd�ntjj|j�ssytj|j�Wqstjk
rotjd|j�gSXntj	jj
|jdj|djtjj
d���}tj	jj
|jdj|djtjj
d���}tjj|j|||�\}}}|d
k	r|S|rAit�d6id6t�d	6}tj	jj|d�st|d|j�kr�xm|jD]_}	|	j|d�\}
}|dj|
�|dj|�|d	j|	j|d��q~Wnt|d�|d<t|d	�|d	<|r1tjj|j|||�n|j|g�S|dkrQiSgS(uL
        Return a dict containing the file lists for files and dirs
        uenvuUnable to make cachedir %su{0}.pusaltenvu_|-u.{0}.wufilesusymlinksudirsN(R�RjRgRkR�RlR%R$R9R:RGR+treplaceR�R�tcheck_file_list_cacheR8R
R�R�R�RRMRRQRR�twrite_file_list_cacheR=(RpRtformt
list_cachetw_lockRt
refresh_cachet
save_cacheRR7t
repo_filest
repo_symlinks((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyResD((	!%	cC@s|j|d�S(ub
        Return a list of all files on the file server in a specified
        environment
        ufiles(R(RpR((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�scC@sgS(uF
        Return a list of all empty directories on the master
        ((RpR((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytfile_list_emptydirs�scC@s�d|kr|jd�ntjjj|d�rP|d|j�krPiSd|krr|djd�}nd}|j|d�}tgt	j
|�D]'\}}|j|�r�||f^q��S(uQ
        Return a dict of all symlinks based on a given path in the repo
        uenvusaltenvuprefixu/uusymlinks(R�R9R:R�R�RR"RRHRRCR�(RpRR�R`RR&((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pytsymlink_list�sN(((RR0R1R,tweakreftWeakKeyDictionaryRR
RR>RR�RRMRRR,R0RRR;R<(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRq
s$#	d	!	$	3		t	GitPillarcB@s&eZdZdZd�Zd�ZRS(u;
    Functionality specific to the git external pillar
    u
git_pillarcC@s;t�|_g|_x|jD]}|j|�}|dk	r|jdkr�t|d�r�|jj	d�p�|jj	d�p�d}nW|j
r�|j
}nB|j|jkr�d}n'|j�}||jkr�dn|}|j
r#|j|�r0||j|j<|jj|j�q0q3||j|<qqWdS(uQ
        Checkout the targeted branches/tags from the git_pillar remotes
        u__env__uall_saltenvsu	pillarenvusaltenvubaseN(Rtpillar_dirstpillar_linked_dirsRMRR
RRUR8R=R�R�RR"tlink_mountpointRiR�(RpR7RhR�ttgt((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR�s(					c
C@s}tjjj|j|j�}tjjj|j|j��jt	j
�}t}t}y�|jdddd���t
t	j|jdt��}||jkr�tjd|j�tjd|�tjd|j�t}nItd	�|d
 D��stjd|�t}ntjjj|�s0t}n�ytjjj|�}Wn'tk
rrtjd|�t}n�X||kr(tjd
|||�yUtjjj�r�|jd�r�t	jj|�r�tj|�n
t	j|�Wn,tk
r}tjd||j��nXt}t}n|r�t}ytj|j�Wnt k
r[nXy3t	jj!|�}	t	j"|	�tjd|	�Wq�t k
r�}tj#d|	|j��tSXn|r)y+t	j$||�tjd||�tSWq)t k
r%}tj#d|||j��tSXnWdQXWnFt%k
rxtj#d|j&|j'|j&|j&|j(dd��tSXtS(uv
        Ensure that the mountpoint is present in the correct location and
        points at the correct path
        R�u
mountpointRi
tfollowlinksu2Results of walking %s differ from expected resultsuWalk results: %suExpected results: %scs@s?|]5}tjjj|d�o6tjj|d�VqdS(iN(R9R:RgtislinkRjRk(R5R(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pys	<genexpr>�si����u-Linkdir parents of %s are not all directoriesu Failed to read destination of %su=Destination of %s (%s) does not match the expected value (%s)u\\u;Failed to remove existing git_pillar mountpoint link %s: %su#Successfully made linkdir parent %su-Failed to os.makedirs() linkdir parent %s: %su%Successfully linked %s to cachedir %su-Failed to create symlink to %s at path %s: %sNu�Timed out setting mountpoint lock for %s remote '%s'. If this error persists, it may be because an earlier %s checkout was interrupted. The lock can be cleared by running 'salt-run cache.clear_git_lock %s type=mountpoint', or by manually removing %s.()R9R:RgRGRiR"RhR�R�RjR�RMR�R twalkR)R$RZR>R�REtreadlinkR#R�R�R�RkR�R�R�t	exceptiont__str__R�R�RlR%tsymlinkRR,RKR�(
RpR7t
lcachelinkt
lcachedesttwipe_linkdirtcreate_linktwalk_resultstldestR)tldirname((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRB�s�-
				



	



(RR0R1R,RRB(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyR?�s	tWinRepocB@s#eZdZdZiZd�ZRS(u6
    Functionality specific to the winrepo runner
    uwinrepocC@sOi|_x?|jD]4}|j|�}|dk	r||j|j<qqWdS(uN
        Checkout the targeted branches/tags from the winrepo remotes
        N(twinrepo_dirsRMRR
RK(RpR7Rh((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRZs
	(RR0R1R,RSR(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyRRQs(iR1t
__future__RRRR@R3R�R�RRatloggingRjR�R�RYR�Rttornado.ioloopRR=Rtsalt.utils.configparserR9tsalt.utils.datatsalt.utils.filestsalt.utils.gzip_utiltsalt.utils.hashutilstsalt.utils.itertoolstsalt.utils.pathtsalt.utils.platformtsalt.utils.stringutilstsalt.utils.urltsalt.utils.usertsalt.utils.versionstsalt.fileservertsalt.configRRXtsalt.utils.odictRtsalt.utils.processRR�tsalt.exceptionsRRR	tsalt.utils.eventR
RR�tsalt.extRR`RRReRPRNRTR�R�RCt	getLoggerRR$R:Rkt__version__R�R#R
R�tcatch_warningstsimplefilterRR�R�t
pygit2.ffit
pygit2.remotetImportErrorRRqtmaybe_stringR�R�R�R)RRHR�R�R�R*R-R
R.RoRnR�R�RR?RR(((s4/usr/lib/python2.7/site-packages/salt/utils/gitfs.pyt<module>s�
			




	
	6	�����$���
��Z�K�

Zerion Mini Shell 1.0