Ejemplo n.º 1
0
 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     args_output = SYM_EMPTY.join([
         SYM_EMPTY.join((SYM_DOLLAR, b(str(len(k))), SYM_CRLF, k, SYM_CRLF))
         for k in imap(self.encode, args)])
     output = SYM_EMPTY.join(
         (SYM_STAR, b(str(len(args))), SYM_CRLF, args_output))
     return output
Ejemplo n.º 2
0
 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     args_output = SYM_EMPTY.join([
         SYM_EMPTY.join((SYM_DOLLAR, b(str(len(k))), SYM_CRLF, k, SYM_CRLF))
         for k in imap(self.encode, args)
     ])
     output = SYM_EMPTY.join(
         (SYM_STAR, b(str(len(args))), SYM_CRLF, args_output))
     return output
Ejemplo n.º 3
0
 def pack_command(self, *args):
     "Pack a series of arguments into a value Redis command"
     output = SYM_STAR + b(str(len(args))) + SYM_CRLF
     for enc_value in imap(self.encode, args):
         output += SYM_DOLLAR
         output += b(str(len(enc_value)))
         output += SYM_CRLF
         output += enc_value
         output += SYM_CRLF
     return output
Ejemplo n.º 4
0
                             Empty, Full)
from pyredis.exceptions import (
    RedisError,
    ConnectionError,
    BusyLoadingError,
    ResponseError,
    InvalidResponse,
    AuthenticationError,
    NoScriptError,
    ExecAbortError,
)
from pyredis.utils import HIREDIS_AVAILABLE
if HIREDIS_AVAILABLE:
    import hiredis

SYM_STAR = b('*')
SYM_DOLLAR = b('$')
SYM_CRLF = b('\r\n')
SYM_LF = b('\n')
SYM_EMPTY = b('')


class PythonParser(object):
    "Plain Python parsing class"
    MAX_READ_LENGTH = 1000000
    encoding = None

    EXCEPTION_CLASSES = {
        'ERR': ResponseError,
        'EXECABORT': ExecAbortError,
        'LOADING': BusyLoadingError,
Ejemplo n.º 5
0
    ConnectionError,
    ResponseError,
    InvalidResponse,
    AuthenticationError,
    NoScriptError,
    ExecAbortError,
)

try:
    import hiredis
    hiredis_available = True
except ImportError:
    hiredis_available = False


SYM_STAR = b('*')
SYM_DOLLAR = b('$')
SYM_CRLF = b('\r\n')
SYM_LF = b('\n')


class PythonParser(object):
    "Plain Python parsing class"
    MAX_READ_LENGTH = 1000000
    encoding = None

    EXCEPTION_CLASSES = {
        'ERR': ResponseError,
        'NOSCRIPT': NoScriptError,
        'EXECABORT': ExecAbortError,
    }