Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/__pycache__/server.cpython-35.pyc



�D�Z(�@s�ddlmZddlmZmZmZmZddlmZGdd�d�Z	dd�Z
dd	�Zd
d�Zdd
�Z
edd�Zedd�Zedd�Zedd�Zdd�ZdS)�)�
namedtuple)�wait_ok�wait_convert�wait_make_dict�_NOTSET)�loggerc@s�eZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	e
dd
�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdddd�Zdd�Zddd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0d1�Zd/d2d3�Zd4d5d6�Zd7d8�Zd9d:�Zd;d<�Z d=d>�Z!d?d@dA�Z"e
d?dBdC�Z#d?dDdE�Z$dFdG�Z%dHdI�Z&dJdK�Z'dLdM�Z(d?S)N�ServerCommandsMixinz[Server commands mixin.

    For commands details see: http://redis.io/commands/#server
    �
SHUTDOWN_SAVE�SHUTDOWN_NOSAVEcCs|jd�}t|�S)z,Asynchronously rewrite the append-only file.sBGREWRITEAOF)�executer)�self�fut�r�I/opt/alt/python35/lib/python3.5/site-packages/aioredis/commands/server.py�bgrewriteaofsz ServerCommandsMixin.bgrewriteaofcCs|jd�}t|�S)z(Asynchronously save the dataset to disk.sBGSAVE)rr)rr
rrr�bgsaveszServerCommandsMixin.bgsavecCs
t�dS)zOKill the connection of a client.

        .. warning:: Not Implemented
        N)�NotImplementedError)rrrr�client_killszServerCommandsMixin.client_killcCs%|jdddd�}t|t�S)z^Get the list of client connections.

        Returns list of ClientInfo named tuples.
        sCLIENTsLIST�encodingzutf-8)rr�	to_tuples)rr
rrr�client_list!szServerCommandsMixin.client_listcCs|jddd|�S)z Get the current connection name.sCLIENTsGETNAMEr)r)rrrrr�client_getname)sz"ServerCommandsMixin.client_getnamecCsRt|t�std��|dkr3td��|jdd|�}t|�S)z�Stop processing commands from clients for *timeout* milliseconds.

        :raises TypeError: if timeout is not int
        :raises ValueError: if timeout is less then 0
        ztimeout argument must be intrztimeout must be greater equal 0sCLIENTsPAUSE)�
isinstance�int�	TypeError�
ValueErrorrr)r�timeoutr
rrr�client_pause-sz ServerCommandsMixin.client_pausecCs
t��dS)N)r)rrrr�client_reply:sz ServerCommandsMixin.client_replycCs|jdd|�}t|�S)z Set the current connection name.sCLIENTsSETNAME)rr)r�namer
rrr�client_setname=sz"ServerCommandsMixin.client_setnamecCs|jddd�S)zGet array of Redis commands.sCOMMANDrzutf-8)r)rrrr�commandBszServerCommandsMixin.commandcCs|jdd�S)z#Get total number of Redis commands.sCOMMANDsCOUNT)r)rrrr�
command_countGsz!ServerCommandsMixin.command_countrzutf-8cGs|jdd||d|�S)z(Extract keys given a full Redis command.sCOMMANDsGETKEYSr)r)rr!r�argsrrr�command_getkeysKsz#ServerCommandsMixin.command_getkeyscGs|jdd||dd�S)z,Get array of specific Redis command details.sCOMMANDsINFOrzutf-8)r)rr!�commandsrrr�command_infoPsz ServerCommandsMixin.command_info�*cCs@t|t�std��|jdd|dd�}t|�S)z�Get the value of a configuration parameter(s).

        If called without argument will return all parameters.

        :raises TypeError: if parameter is not string
        zparameter must be strsCONFIGsGETrzutf-8)r�strrrr)r�	parameterr
rrr�
config_getUszServerCommandsMixin.config_getcCs|jdd�}t|�S)z@Rewrite the configuration file with the in memory configuration.sCONFIGsREWRITE)rr)rr
rrr�config_rewriteasz"ServerCommandsMixin.config_rewritecCs=t|t�std��|jdd||�}t|�S)z1Set a configuration parameter to the given value.zparameter must be strsCONFIGsSET)rr(rrr)rr)�valuer
rrr�
config_setfszServerCommandsMixin.config_setcCs|jdd�}t|�S)z!Reset the stats returned by INFO.sCONFIGs	RESETSTAT)rr)rr
rrr�config_resetstatmsz$ServerCommandsMixin.config_resetstatcCs
|jd�S)z3Return the number of keys in the selected database.sDBSIZE)r)rrrr�dbsizerszServerCommandsMixin.dbsizecCs|jdd|�}t|�S)z'Suspend connection for timeout seconds.sDEBUGsSLEEP)rr)rrr
rrr�debug_sleepvszServerCommandsMixin.debug_sleepcCs|jdd|�S)z&Get debugging information about a key.sDEBUGsOBJECT)r)r�keyrrr�debug_object{sz ServerCommandsMixin.debug_objectcCs|jdd�S)zMake the server crash.sDEBUGZSEGFAULT)r)rr1rrr�debug_segfaultsz"ServerCommandsMixin.debug_segfaultFcCs4|r|jdd�}n|jd�}t|�S)z�
        Remove all keys from all databases.

        :param async_op: lets the entire dataset to be freed asynchronously.         Defaults to False
        sFLUSHALLsASYNC)rr)r�async_opr
rrr�flushall�szServerCommandsMixin.flushallcCs4|r|jdd�}n|jd�}t|�S)z�
        Remove all keys from the current database.

        :param async_op: lets a single database to be freed asynchronously.         Defaults to False
        sFLUSHDBsASYNC)rr)rr4r
rrr�flushdb�szServerCommandsMixin.flushdb�defaultcCs7|std��|jd|dd�}t|t�S)z�Get information and statistics about the server.

        If called without argument will return default set of sections.
        For available sections, see http://redis.io/commands/INFO

        :raises ValueError: if section is invalid

        zinvalid sectionsINFOrzutf-8)rrr�
parse_info)r�sectionr
rrr�info�s	zServerCommandsMixin.infocCs
|jd�S)z<Get the UNIX time stamp of the last successful save to disk.sLASTSAVE)r)rrrr�lastsave�szServerCommandsMixin.lastsavecCs
t�dS)z�Listen for all requests received by the server in real time.

        .. warning::
           Will not be implemented for now.
        N)r)rrrr�monitor�szServerCommandsMixin.monitorcCs"|jddd�}t|t�S)z�Return the role of the server instance.

        Returns named tuples describing role of the instance.
        For fields information see http://redis.io/commands/role#output-format
        sROLErzutf-8)rr�
parse_role)rr
rrr�role�szServerCommandsMixin.rolecCs
|jd�S)z'Synchronously save the dataset to disk.sSAVE)r)rrrr�save�szServerCommandsMixin.saveNcCsO||jkr|jdd�S||jkr>|jdd�S|jd�SdS)zVSynchronously save the dataset to disk and then
        shut down the server.
        sSHUTDOWNsSAVEsNOSAVEN)r	rr
)rr?rrr�shutdown�s
zServerCommandsMixin.shutdowncCs]|tkrtjd�d}|dkrJ|dkrJ|jddd�S|jd||�S)aMake the server a slave of another instance,
        or promote it as master.

        Calling ``slaveof(None)`` will send ``SLAVEOF NO ONE``.

        .. versionchanged:: v0.2.6
           ``slaveof()`` form deprecated
           in favour of explicit ``slaveof(None)``.
        zLslaveof() form is deprecated! Use slaveof(None) to turn redis into a MASTER.NsSLAVEOFsNOsONE)rrZwarningr)r�host�portrrr�slaveof�s

zServerCommandsMixin.slaveofcCsN|dk	r:t|t�s'td��|jdd|�S|jdd�SdS)z#Returns the Redis slow queries log.Nzlength must be int or NonesSLOWLOGsGET)rrrr)r�lengthrrr�slowlog_get�s
zServerCommandsMixin.slowlog_getcCs|jdd�S)z)Returns length of Redis slow queries log.sSLOWLOGsLEN)r)rrrr�slowlog_len�szServerCommandsMixin.slowlog_lencCs|jdd�}t|�S)zResets Redis slow queries log.sSLOWLOGsRESET)rr)rr
rrr�
slowlog_reset�sz!ServerCommandsMixin.slowlog_resetcCs
|jd�S)z3Redis-server internal command used for replication.sSYNC)r)rrrr�sync�szServerCommandsMixin.synccCs|jd�}t|t�S)zReturn current server time.sTIME)rr�to_time)rr
rrr�time�szServerCommandsMixin.time))�__name__�
__module__�__qualname__�__doc__r	r
rrrrrrrrr r!r"r$r&r*r+r-r.r/r0r2r3r5r6r:r;r<r>r?r@rCrErFrGrHrJrrrrrsJ


			rcCs+|jd�\}}|jdd�|fS)N�=�-�_)�split�replace)�s�k�vrrr�_splitsrWcCs t|d�t|d�dS)Nr�g���ư>)r)�objrrrrIsrIcCs�|jd�^}}ttt|jd���}tddjdd�|D���}|t|��g}x9|D]1}|j|ttt|jd�����qtW|S)NF� �
ClientInfocss|]\}}|VqdS)Nr)�.0rUrVrrr�	<genexpr>szto_tuples.<locals>.<genexpr>)	�
splitlines�list�maprWrRr�join�dict�append)r,�line�linesr[�resultrrrr	s%
/rcCs�i}x�|jd�D]�}|j�j�^}}|dd�j�}i||<}xi|D]a}|jd�\}}d|kr�d|kr�ttdd�|jd���}|||<q_WqW|S)Nz

��:�,rOcSs
|jd�S)NrO)rR)�irrr�<lambda>szparse_info.<locals>.<lambda>)rR�stripr^�lowerrbr`)r:�res�blockr9�tmprdr1r,rrrr8s
$r8�
MasterInfozrole replication_offset slaves�MasterSlaveInfozip port ack_offset�	SlaveInfoz)role master_ip master_port state received�SentinelInfozrole masterscCs�|d}|dkrKdd�|dD�}t|dt|d�|�S|dkr�t|d|dt|d�|dt|d	��S|d
kr�t|�S|S)NrZmastercSs:g|]0}t|dt|d�t|d���qS)rrXrg)rrr)r\rTrrr�
<listcomp>0s	zparse_role.<locals>.<listcomp>rgrXZslave���sentinel)rqrrsrt)r>�type_Zslavesrrrr=-s
	6
r=N)�collectionsrZ
aioredis.utilrrrrZaioredis.logrrrWrIrr8rqrrrsrtr=rrrr�<module>s"�