%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/alternatives.pyc

�
���^c@@s	dZddlmZmZmZddlZddlZddlZddl	Zddl
mZidd6dd6dd6Zej
e�Zid	d
6Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS(uQ
Support for Alternatives system

:codeauthor: Radek Rada <radek.rada@gmail.com>
i(tabsolute_importtprint_functiontunicode_literalsN(tsixutxtudisplayuinstalluremoveusetuset_cC@s tjjd�rtStdfS(u/
    Only if alternatives dir is available
    u/etc/alternativesu@Cannot load alternatives module: /etc/alternatives dir not found(tostpathtisdirtTruetFalse(((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pyt__virtual__#scC@stddkrdSdS(u>
    Alteratives commands and differ across distributions
    u	os_familyuRedHatualternativesuupdate-alternatives(t
__grains__(((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pyt_get_cmd,scC@sXt�d|g}td|dt�}|ddkrP|ddkrP|dS|dS(	u�
    Display alternatives settings for defined command name

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.display editor
    u	--displayucmd.run_alltpython_shelluretcodeiustderruustdout(Rt__salt__R(tnametcmdtout((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytdisplay5s

 cC@s�tddkrd}ntddkr2d}nd}|dj|�7}yZtjjj|d��<}tjjj|j��}|j	t
�d	jd
�SWdQXWnLtk
r�t
jd|�n,ttfk
r�}t
jd
||�nXtS(u�
    Display master link for the alternative

    .. versionadded:: 2015.8.13,2016.3.4,2016.11.0

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.show_link editor
    u	os_familyuRedHatu	/var/lib/uSuseu
/var/lib/rpm/u/var/lib/dpkg/ualternatives/{0}urbiu
Nualternatives: %s does not existu=alternatives: unable to get master link for %s. Exception: %s(R
tformattsalttutilstfilestfopentstringutilst
to_unicodetreadt
splitlinesRtrstriptOSErrortlogterrortIOErrort
IndexErrorR(RRtr_filetcontentstexc((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pyt	show_linkFs"
		$
cC@s6yt|�SWn!tk
r1tjd|�nXtS(u�
    Display the current highest-priority alternative for a given alternatives
    link

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.show_current editor
    ualternative: %s does not exist(t
_read_linkRRRR(R((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytshow_currentks

c@spt�d|g}td|dt�}|ddkrL|ddkrLtSt�fd�|d	j�D��S(
u�
    Check if the given path is an alternative for a name.

    .. versionadded:: 2015.8.4

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.check_exists name path
    u	--displayucmd.run_allRuretcodeiustderruc3@s|]}|j��VqdS(N(t
startswith(t.0tline(R(s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pys	<genexpr>�sustdout(RR
RtanyR(RRRR((Rs=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytcheck_exists}s
 cC@s-yt|�|kSWntk
r(tSXdS(u�
    Check if the current highest-priority match for a given alternatives link
    is set to the desired path

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.check_installed name path
    N(R%RR(RR((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytcheck_installed�s
cC@sjt�d|||tj|�g}td|dt�}|ddkrb|ddkrb|dS|dS(	u�
    Install symbolic links determining default commands

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.install editor /usr/bin/editor /usr/bin/emacs23 50
    u	--installucmd.run_allRuretcodeiustderruustdout(RRt	text_typeR
R(RtlinkRtpriorityRR((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytinstall�s

$ cC@sKt�d||g}td|dt�}|ddkrC|dS|dS(u�
    Remove symbolic links determining the default commands.

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.remove name path
    u--removeucmd.run_allRuretcodeiustderrustdout(RR
R(RRRR((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytremove�s

cC@sHt�d|g}td|dt�}|ddkr@|dS|dS(u�
    Trigger alternatives to set the path for <name> as
    specified by priority.

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.auto name
    u--autoucmd.run_allRuretcodeiustderrustdout(RR
R(RRR((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytauto�s
cC@sKt�d||g}td|dt�}|ddkrC|dS|dS(u�
    Manually set the alternative <path> for <name>.

    CLI Example:

    .. code-block:: bash

        salt '*' alternatives.set name path
    u--setucmd.run_allRuretcodeiustderrustdout(RR
R(RRRR((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pytset_�s

cC@s"dj|�}tjjj|�S(u`
    Read the link from /etc/alternatives

    Throws an OSError if the link does not exist
    u/etc/alternatives/{0}(RRRRtreadlink(Rt
alt_link_path((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pyR%�s(t__doc__t
__future__RRRRtloggingtsalt.utils.filesRtsalt.utils.pathtsalt.extRt
__outputter__t	getLoggert__name__Rt__func_alias__R	RRR$R&R+R,R0R1R2R3R%(((s=/usr/lib/python2.7/site-packages/salt/modules/alternatives.pyt<module>s2

						%							

Zerion Mini Shell 1.0