Example #1
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
Example #2
0
    RedisError,
    ConnectionError,
    ResponseError,
    InvalidResponse,
    AuthenticationError,
    NoScriptError,
)

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,
    }