Pack a series of arguments into the Redis protocol
550423
def pack_command(self, *args):
        ""
        output = []
        # the client might have included 1 or more literal arguments in
        # the command name, e.g., 'CONFIG GET'. The Redis server expects these
        # arguments to be sent separately, so split the first argument
        # manually. All of these arguements get wrapped in the Token class
        # to prevent them from being encoded.
        command = args[0]
        if ' ' in command:
            args = tuple([b(s) for s in command.split()]) + args[1:]
        else:
            args = (b(command),) + args[1:]

        buff = SYM_EMPTY.join(
            (SYM_STAR, b(str(len(args))), SYM_CRLF))
        for arg in map(self.encode, args):
            # to avoid large string mallocs, chunk the command into the
            # output list if we're sending large values
            if len(buff) > 6000 or len(arg) > 6000:
                buff = SYM_EMPTY.join(
                    (buff, SYM_DOLLAR, b(str(len(arg))), SYM_CRLF))
                output.append(buff)
                output.append(b(arg))
                buff = SYM_CRLF
            else:
                buff = SYM_EMPTY.join((buff, SYM_DOLLAR, b(str(len(arg))),
                                       SYM_CRLF, b(arg), SYM_CRLF))
        output.append(buff)
        return output
679494
def _expand_args(command):
    """"""

    # Prepare arguments.
    if isinstance(command, STR_TYPES):
        if sys.version_info[0] == 2:
            splitter = shlex.shlex(command.encode("utf-8"))
        elif sys.version_info[0] == 3:
            splitter = shlex.shlex(command)
        else:
            splitter = shlex.shlex(command.encode("utf-8"))
        splitter.whitespace = "|"
        splitter.whitespace_split = True
        command = []

        while True:
            token = splitter.get_token()
            if token:
                command.append(token)
            else:
                break

        command = list(map(shlex.split, command))

    return command
539803
function wrapRemoteCache(remoteCache) {
    return {
        get: function (key) {
            var deferred = Q.defer();

            remoteCache.get(key, function (err, value) {
                if (err) {
                    console.log('redis remoteCache.get err ' + err);
                    deferred.resolve();
                }

                if (_.isString(value) && value.charAt(0) === '{') {
                    value = JSON.parse(value);
                }

                deferred.resolve(value);
            });

            return deferred.promise;
        },
        set: function (key, value) {
            value = _.isObject(value) ? JSON.stringify(value) : value;
            remoteCache.set(key, value);
            remoteCache.expire(key, 3600);
        },
        del: function (key) {
            remoteCache.del(key);
        },
        quit: function () {
            remoteCache.quit();
        },
        flush: function () {
            remoteCache.flushdb();
        }
    };
}
335172
def execute(self, requests, resp_generator, *args, **kwargs):
        '''
            
        '''
        return [resp_generator(request) for request in requests]
1312663
function arity(cmd, args, info, sub) {
  var subcommand = sub !== undefined;

  // command validation decorated the info
  var def = sub || info.command.def
    , expected = def.arity
    , first = def.first
    , last = def.last
    , step = def.step
    , min = Math.abs(expected)
    , max
    // account for command, redis includes command
    // in the arity
    , count = args.length + 1;

  //console.dir(def);

  // only command is allowed - zero args (COMMAND etc)
  if(expected === 0 && first === 0 && last === 0) {
    min = max = 1;
  // positive fixed args length (TYPE etc)
  }else if(expected > 0) {
    min = max = expected;
  // variable length arguments (MGET/MSET etc)
  }else{
    max = Number.MAX_VALUE;
    // test for step
    if(step > 1 && (args.length % step !== 0)) {
      throw new CommandArgLength(cmd);
    }
  }

  // made it this far, check subcommands
  // for commands that require a subcommand
  if(!subcommand && Constants.SUBCOMMAND[cmd] && args.length && arity !== 1) {
    sub = Constants.SUBCOMMAND[cmd][args[0]];
    arity(args[0], args.slice(1), info, sub);
  }else if(count < min || count > max) {
    if(subcommand) throw UnknownSubcommand;
    throw new CommandArgLength(cmd);
  }

  return true;
}
1040117
def hstrlen(self, name, key):
        
        with self.pipe as pipe:
            return pipe.hstrlen(self.redis_key(name), key)
68268
def process_arguments(args):
    """"""
    if args.sentryconfig:
        print('Parsing DSN from %s' % args.sentryconfig)
        os.environ['SENTRY_DSN'] = parse_sentry_configuration(args.sentryconfig)

    if args.sentrydsn:
        print('Using the DSN %s' % args.sentrydsn)
        os.environ['SENTRY_DSN'] = args.sentrydsn

    if args.nginxerrorpath:
        print('Using the Nginx error log path %s' % args.nginxerrorpath)
        os.environ['NGINX_ERROR_PATH'] = args.nginxerrorpath

    from ..conf import settings  # noqa; pylint: disable=unused-variable

    if args.daemonize:
        print('Running process in background')
        from ..daemonize import create_daemon
        create_daemon()
267085
def mget(self, keys, *args):
        
        keys = [self.redis_key(k) for k in self._parse_values(keys, args)]
        with self.pipe as pipe:
            f = Future()
            res = pipe.mget(keys)

            def cb():
                decode = self.valueparse.decode
                f.set([None if r is None else decode(r) for r in res.result])

            pipe.on_execute(cb)
            return f
465989
def lrange(self, name, start, stop):
        
        with self.pipe as pipe:
            f = Future()
            res = pipe.lrange(self.redis_key(name), start, stop)

            def cb():
                f.set([self.valueparse.decode(v) for v in res.result])

            pipe.on_execute(cb)
            return f
247358
def set(self, key, value):
        """"""
        value = pickle.dumps(value, protocol=constants.PICKLE_PROTOCOL)
        redis_conn.set(key, value)
1313269
def _custom_argv(argv):
    """"""
    backup_argv = sys.argv
    sys.argv = backup_argv[:1] + argv
    try:
        yield
    finally:
        sys.argv = backup_argv
830063
def iteritems(self, pipe=None):
        """"""
        pipe = self.redis if pipe is None else pipe
        for k, v in self._data(pipe).items():
            yield k, self.cache.get(k, v)
397313
def hmget(self, name, keys, *args):
        
        member_encode = self.memberparse.encode
        keys = [k for k in self._parse_values(keys, args)]
        with self.pipe as pipe:
            f = Future()
            res = pipe.hmget(self.redis_key(name),
                             [member_encode(k) for k in keys])

            def cb():
                f.set([self._value_decode(keys[i], v)
                       for i, v in enumerate(res.result)])

            pipe.on_execute(cb)
            return f
127637
def _set_named_args(self, **kv):
        
        for k in kv:
            self._body['${0}'.format(k)] = kv[k]
        return self
114233
def convert_arguments(value):
    """"""
    if isinstance(value, (list, tuple)):
        return [
            CommandLineBinding(**item) if isinstance(item, dict) else item
            for item in value
        ]
    return shlex.split(value)
689707
def msetnx(self, *args, **kwargs):
        
        if args:
            if len(args) != 1 or not isinstance(args[0], dict):
                raise RedisError('MSETNX requires **kwargs or a single dict arg')
            mapping = args[0]
        else:
            mapping = kwargs

        if len(mapping) == 0:
            raise ResponseError("wrong number of arguments for 'msetnx' command")

        for key in mapping.keys():
            if self._encode(key) in self.redis:
                return False
        for key, value in mapping.items():
            self.set(key, value)

        return True
531995
def parse_kv_args(self, args):
        """"""
        for arg in ["start", "end", "count", "stride"]:
            try:
                arg_raw = args.pop(arg, None)
                if arg_raw is None:
                    continue
                arg_cooked = int(arg_raw, 0)
                setattr(self, arg, arg_cooked)
            except ValueError:
                raise AnsibleError(
                    "can't parse arg %s=%r as integer"
                        % (arg, arg_raw)
                )
            if 'format' in args:
                self.format = args.pop("format")
        if args:
            raise AnsibleError(
                "unrecognized arguments to with_sequence: %r"
                % args.keys()
            )