%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/memcached.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlm	Z	m
Z
ddlmZyddl
Z
eZWnek
r�eZnXdZdZdZdZeje�Zidd	6Zd
Zd�Zeed�Zd
�Zeed�Zeed�Zeeeed�Z eeed�Z!eeeed�Z"eeeed�Z#deed�Z$ej%j&j'e$d�Z(deed�Z)ej%j&j'e)d�Z*dS(uE
Module for Management of Memcached Keys

.. versionadded:: 2014.1.0
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortSaltInvocationError(tsixu	127.0.0.1i�+usetuset_u	memcachedcC@str
tStdfS(u3
    Only load if python-memcache is installed
    uWThe memcached execution module cannot be loaded: python memcache library not available.(tHAS_MEMCACHEt__virtualname__tFalse(((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt__virtual__)scC@sGtj|�j�r7tjdj||�gdd�Std��dS(uv
    Returns a tuple of (user, host, port) with config, pillar, or default
    values assigned to missing values.
    u{0}:{1}tdebugiuport must be an integerN(Rt	text_typetisdigittmemcachetClienttformatR(thosttport((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt_connect3s"cC@s%|j�}|s!td��n|S(u�
    Helper function to check the stats data passed into it, and raise an
    exception if none are returned. Otherwise, the stats are returned.
    u*memcached server is down or does not exist(t	get_statsR(tconntstats((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt_check_stats=s
cC@sUt||�}yt|�d}Wnttfk
r=tSXi|d|d6SdS(um
    Get memcached status

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.status
    iiN(RRRt
IndexErrorR(RRRR((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pytstatusJs
cC@s&t||�}t|�|j|�S(ut
    Retrieve value for a key

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.get <key>
    (RRtget(tkeyRRR((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyR]s

cC@sqt|tj�s!td��nt|tj�sBtd��nt||�}t|�|j||||�S(u�
    Set a key on the memcached server, overwriting the value if it exists.

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.set <key> <value>
    u'time' must be an integeru%'min_compress_len' must be an integer(t
isinstanceRt
integer_typesRRRtset(RtvalueRRttimetmin_compress_lenR((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pytset_ls
cC@sPt|tj�s!td��nt||�}t|�t|j||��S(u�
    Delete a key from memcache server

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.delete <key>
    u'time' must be an integer(RRRRRRtbooltdelete(RRRRR((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyR#�s


cC@swt|tj�s!td��nt|tj�sBtd��nt||�}t|�|j||d|d|�S(u�
    Add a key to the memcached server, but only if it does not exist. Returns
    False if the key already exists.

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.add <key> <value>
    u'time' must be an integeru%'min_compress_len' must be an integerRR (RRRRRRtadd(RRRRRR R((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyR$�s
cC@syt|tj�s!td��nt|tj�sBtd��nt||�}|j�}|j||d|d|�S(u
    Replace a key on the memcached server. This only succeeds if the key
    already exists. This is the opposite of :mod:`memcached.add
    <salt.modules.memcached.add>`

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.replace <key> <value>
    u'time' must be an integeru%'min_compress_len' must be an integerRR (RRRRRRtreplace(RRRRRR RR((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyR%�sicC@s�t||�}t|�t|�}|dkrItdj|���n*t|tj�sstdj|���ny|j	||�SWnt
k
r�td��nXdS(u�
    Increment the value of a key

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.increment <key>
        salt '*' memcached.increment <key> 2
    uKey '{0}' does not existu8Value for key '{0}' must be an integer to be incrementeduDelta value must be an integerN(RRRtNoneRRRRRtincrt
ValueErrorR(RtdeltaRRRtcur((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt	increment�s

uincrcC@s�t||�}t|�t|�}|dkrItdj|���n*t|tj�sstdj|���ny|j	||�SWnt
k
r�td��nXdS(u�
    Decrement the value of a key

    CLI Example:

    .. code-block:: bash

        salt '*' memcached.decrement <key>
        salt '*' memcached.decrement <key> 2
    uKey '{0}' does not existu8Value for key '{0}' must be an integer to be decrementeduDelta value must be an integerN(RRRR&RRRRRtdecrR(R(RR)RRRR*((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt	decrement�s

udecr(+t__doc__t
__future__RRRtloggingtsalt.utils.functoolstsalttsalt.exceptionsRRtsalt.extRR
tTrueRtImportErrorRtDEFAULT_HOSTtDEFAULT_PORTtDEFAULT_TIMEtDEFAULT_MIN_COMPRESS_LENt	getLoggert__name__tlogt__func_alias__RR	RRRRR!R#R$R%R+tutilst	functoolstalias_functionR'R-R,(((s:/usr/lib/python2.7/site-packages/salt/modules/memcached.pyt<module>sT



	

	


Zerion Mini Shell 1.0