Logo Search packages:      
Sourcecode: hellanzb version File versions  Download package

def Hellanzb::NZBLeecher::NZBLeecher::dataReceivedToFile (   self,
  data 
)

Dump the raw recieved data to the current segment's encoded-data-temp file. This
function is faster than parsing the received data into individual lines
(dataReceivedToLines) -- it simply dumps the data to file, and looks for the EOF
string for usenet messages: "\r\n.\r\n".

It manually rstrip()s every chunk of data received, then matches both the
rstripped data and rstripped-off data with their associated usenet EOF pieces (to
safely detect the EOF across potentially two data chunks)

It is smarter about parsing the usenet response code (lineReceived does this for
dataReceivedToLines and is lazier about it)

Ultimately, significantly less work than dataReceivedToLines 

Definition at line 815 of file __init__.py.

00815                                       :
        """ Dump the raw recieved data to the current segment's encoded-data-temp file. This
        function is faster than parsing the received data into individual lines
        (dataReceivedToLines) -- it simply dumps the data to file, and looks for the EOF
        string for usenet messages: "\r\n.\r\n".

        It manually rstrip()s every chunk of data received, then matches both the
        rstripped data and rstripped-off data with their associated usenet EOF pieces (to
        safely detect the EOF across potentially two data chunks)

        It is smarter about parsing the usenet response code (lineReceived does this for
        dataReceivedToLines and is lazier about it)
        
        Ultimately, significantly less work than dataReceivedToLines """
        if not self.gotResponseCode:
            # find the nntp response in the header of the message (the BODY command)
            if self.lastChunk == '':
                data = data.lstrip()
            else:
                data = self.lastChunk + data
                
            off = data.find(self.delimiter)
            if off == -1:
                # Haven't received the entire first line yet
                self.lastChunk = data
                return
            
            line = data[:off]

            code = extractCode(line)
            if code is None or (not (200 <= code[0] < 400) and code[0] != 100): # An error!
                try:
                    # getBodyFailed or finishedSegmentDownload will close it
                    ##self.currentSegment.encodedData.close()
                    self._error[0](line)
                # FIXME: why is this exception thrown? it was previously breaking
                # connections -- this is now caught to avoid the completely breaking of
                # the connection
                except TypeError, te:
                    debug(str(self) + ' lineReceived GOT TYPE ERROR!: ' + str(te) + ' state name: ' + \
                          self._state[0].__name__ + ' code: ' + str(code) + ' line: ' + line)
                self._endState()
                return
            else:
                self._setResponseCode(code)
                self.gotResponseCode = True
                data = data[off:]
                self.lastChunk = ''

        # write data to disk
        self.currentSegment.encodedData.write(data)

        # save last len(self.EOF) of current article in lastChunk
        if len(data) >= len(self.EOF):
            self.lastChunk = data[-len(self.EOF):]
        else:
            self.lastChunk = self.lastChunk[-(len(self.EOF) - len(data)):] + data

        if self.lastChunk == self.EOF:
            self.gotResponseCode = False
            self.lastChunk = ''
            self.gotBody(self._endState())

    def timeoutConnection(self):


Generated by  Doxygen 1.6.0   Back to index