%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/win_path.pyo

�
���^c@@s;dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
Z	ddlmZy
eZWnek
r�eZnXeje�ZdZdZdZdZeej�Zd	�Zd
�Zd�Z d�Z!d
�Z"d�Z#dd�Z%d�Z&dS(u�
Manage the Windows System PATH

Note that not all Windows applications will rehash the PATH environment variable,
Only the ones that listen to the WM_SETTINGCHANGE message
http://support.microsoft.com/kb/104011
i(tabsolute_importtprint_functiontunicode_literalsN(tmapuHKEY_LOCAL_MACHINEu<SYSTEM\CurrentControlSet\Control\Session Manager\EnvironmentuPATHu
REG_EXPAND_SZcC@s&tjjj�rtrdStdfS(u
    Load only on Windows
    uwin_pathu5Module win_path: module only works on Windows systems(tsalttutilstplatformt
is_windowst	HAS_WIN32tFalse(((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyt__virtual__(scC@s"tjddtjjj|��S(u=
    Normalize the directory to make comparison possible
    u\\$u(tretsubRRtstringutilst
to_unicode(tstring_((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyt_normalize_dir1scC@stjjjd�S(u�
    Send a WM_SETTINGCHANGE Broadcast to Windows to refresh the Environment
    variables for new processes.

    .. note::
        This will only affect new processes that aren't launched by services. To
        apply changes to the path to services, the host must be restarted. The
        ``salt-minion``, if running as a service, will not see changes to the
        environment until the system is restarted. See
        `MSDN Documentation <https://support.microsoft.com/en-us/help/821761/changes-that-you-make-to-environment-variables-do-not-affect-services>`_

    CLI Example:

    .. code-block:: bash

        salt '*' win_path.rehash
    uEnvironment(RRt
win_functionstbroadcast_setting_change(((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pytrehash8scC@sEtjjjtdddd�d�jd�}ttt|��S(u�
    Returns a list of items in the SYSTEM path

    CLI Example:

    .. code-block:: bash

        salt '*' win_path.get_path
    ureg.read_valueuHKEY_LOCAL_MACHINEu<SYSTEM\CurrentControlSet\Control\Session Manager\EnvironmentuPATHuvdatau;(	RRR
Rt__salt__tsplittlistRR(tret((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pytget_pathMs
	cC@s/t|�}t�}|j�d�|D�kS(up
    Check if the directory is configured in the SYSTEM path
    Case-insensitive and ignores trailing backslash

    Returns:
        boolean True if path exists, False if not

    CLI Example:

    .. code-block:: bash

        salt '*' win_path.exists 'c:\python27'
        salt '*' win_path.exists 'c:\python27\'
        salt '*' win_path.exists 'C:\pyThon27'
    cs@s|]}|j�VqdS(N(tlower(t.0tx((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pys	<genexpr>us(RRR(tpathtsysPath((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pytexistsbs	cC@s tj|�tjtd�<dS(NuPATH(tPATHSEPtjointostenvirontstr(t
local_path((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyt_update_local_pathxsc
K@sqtjjj|�}|jdt�}|rCtjjj|�nt|�}tjjj	|�}t
�}gtjdj
t�D]}tjjj	|�^q�}|dk	r�yt|�}Wq�ttfk
r�d}q�Xnd�}||||�rt|�n||||�s"tStdtttdjtjjj|��t�}	|	ri|rit�S|	SdS(u�
    Add the directory to the SYSTEM path in the index location. Returns
    ``True`` if successful, otherwise ``False``.

    path
        Directory to add to path

    index
        Optionally specify an index at which to insert the directory

    rehash : True
        If the registry was updated, and this value is set to ``True``, sends a
        WM_SETTINGCHANGE broadcast to refresh the environment variables. Set
        this to ``False`` to skip this broadcast.

    CLI Examples:

    .. code-block:: bash

        # Will add to the beginning of the path
        salt '*' win_path.add 'c:\python27' 0

        # Will add to the end of the path
        salt '*' win_path.add 'c:\python27' index='-1'
    urehashuPATHcS@s�g|D]}|j�^q}y|j|j��}Wntk
rQd}nXt|�}|}|dk	r�||ks�|dkr�d}q�||kr�d}}q�|dkr�|d7}q�n|dkr(|dk	r||dkr�tS|j|�|j|�tSq�|j|�tSn�|dkrX|dk	rDtS|j|�tSn||dk	r�|dkr�|||ks�|dkr�||kr�|j|�|j	||�tStSn|j	||�tStS(u�
        Check the dir list for the specified path, at the specified index, and
        make changes to the list if needed. Return True if changes were made to
        the list, otherwise return False.
        i����uENDiiN(
Rtindext
ValueErrortNonetlenR	tpoptappendtTruetinsert(tdirsRR&Rtdirs_lct	cur_indextnum_dirstpos((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyt_check_path�sL

		






u
reg.set_valueu;N(RRtargstclean_kwargsR*R,tinvalid_kwargsRR
tto_strRR!R"RRR(tintt	TypeErrorR'R%RtHIVEtKEYtVNAMER tdatatdecodetVTYPER(
RR&tkwargstrehash_tpath_strtsystem_pathRR$R3tresult((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pytadd|s8	5
	^
	c	K@s,tjjj|�}|jdt�}|rCtjjj|�nt|�}tjjj	|�}t
�}gtjdj
t�D]}tjjj	|�^q�}d�}|||�r�t|�n|||�s�tStdtttdjtjjj|��t�}|r$|r$t�S|SdS(u�
    Remove the directory from the SYSTEM path

    Returns:
        boolean True if successful, False if unsuccessful

    rehash : True
        If the registry was updated, and this value is set to ``True``, sends a
        WM_SETTINGCHANGE broadcast to refresh the environment variables. Set
        this to ``False`` to skip this broadcast.

    CLI Example:

    .. code-block:: bash

        # Will remove C:\Python27 from the path
        salt '*' win_path.remove 'c:\\python27'
    urehashuPATHcS@s�g|D]}|j�^q}|j�}g}x:t|�D],\}}||kr>|j||�q>q>Wt|�t|�kr�||(tStSdS(u�
        Check the dir list for the specified path, and make changes to the list
        if needed. Return True if changes were made to the list, otherwise
        return False.
        N(Rt	enumerateR+R)R,R	(R.RRR/tpath_lctnew_dirsR&tdirname((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyR3Dsu
reg.set_valueu;N(RRR4R5R*R,R6RR
R7RR!R"RRR%RR:R;R<R R=R>R?R(	RR@RARBRCRR$R3RD((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pytremove!s.	5	
	('t__doc__t
__future__RRRtloggingR!Rtsalt.utils.argsRtsalt.utils.datatsalt.utils.platformtsalt.utils.stringutilstsalt.utils.win_functionstsalt.ext.six.movesRR,RtImportErrorR	t	getLoggert__name__tlogR:R;R<R?R#tpathsepRR
RRRRR%R(RERJ(((s9/usr/lib/python2.7/site-packages/salt/modules/win_path.pyt<module>s8


							�

Zerion Mini Shell 1.0