示例#1
0
    def parse_tuple(self):
        # see if we've collected enough data
        #log.debug('checking parsing tuple: %s' % self.data)
        if len(self.data) >= self.tuple_byte_size:

            # decode the rep of the tuple
            log.debug('parsing')
            self.tuple_filter = decode_tuple_data(self.data)

            # get rid of our data now that we've used it
            self.data = ""
示例#2
0
    def found_terminator(self):
        # we've gotta line! if we don't have
        # a data size than it's the first line!

        log.debug('TupiliciousHandler: found terminator %s %s %s',
                  len(self.data),self.found,self.response_size)

        if not self.response_size:
            pieces = self.data.split(' ')
            # clean the data out
            self.data = ''
            # see what we've found
            self.found = (pieces[0].lower() == 'found')

            # did we find something ?
            if self.found:
                # if it was found but is a put, just
                # send the callback true
                if self.current_request[0].lower() == 'put':
                    self.response_callback(True)
                    self.clean()
                else:
                    self.response_size = pieces[1]
            else:
                # Not Found! we're done

                # if it was not found but is a put, just
                # send the callback False
                if self.current_request[0].lower() == 'put':
                    self.response_callback(False)
                    self.clean()
                else:
                    self.response_callback(None)
                    self.clean()

        else:
            # this must be the response data
            t = decode_tuple_data(self.data)
            self.data = ''
            self.response_callback(t)
            self.clean()