def sendDAT(self):
        """This method sends the next DAT packet based on the data in the
        context. It returns a boolean indicating whether the transfer is
        finished."""
        finished = False
        blocknumber = self.context.next_block
        # Test hook
        if DELAY_BLOCK and DELAY_BLOCK == blocknumber:
            import time
            log.debug("Deliberately delaying 10 seconds...")
            time.sleep(10)
        dat = None
        blksize = self.context.getBlocksize()
        buffer = self.context.fileobj.read(blksize)
        log.debug("Read %d bytes into buffer", len(buffer))
        if len(buffer) < blksize:
            log.info("Reached EOF on file %s"
                % self.context.file_to_transfer)
            finished = True
        dat = TftpPacketDAT()
        dat.data = buffer
        dat.blocknumber = blocknumber
        self.context.metrics.bytes += len(dat.data)
        log.debug("Sending DAT packet %d", dat.blocknumber)
        self.context.sock.sendto(dat.encode().buffer,
                                 (self.context.host, self.context.tidport))
        if self.context.packethook:
            self.context.packethook(dat)
        self.context.last_pkt = dat
        return finished
def sendDAT ( self ) : finished = False blocknumber = self . context . next_block if DELAY_BLOCK and DELAY_BLOCK == blocknumber : import time log . debug ( "Deliberately delaying 10 seconds..." ) time . sleep ( 10 ) dat = None blksize = self . context . getBlocksize ( ) buffer = self . context . fileobj . read ( blksize ) log . debug ( "Read %d bytes into buffer" , len ( buffer ) ) if len ( buffer ) < blksize : log . info ( "Reached EOF on file %s" % self . context . file_to_transfer ) finished = True dat = TftpPacketDAT ( ) dat . data = buffer dat . blocknumber = blocknumber self . context . metrics . bytes += len ( dat . data ) log . debug ( "Sending DAT packet %d" , dat . blocknumber ) self . context . sock . sendto ( dat . encode ( ) . buffer , ( self . context . host , self . context . tidport ) ) if self . context . packethook : self . context . packethook ( dat ) self . context . last_pkt = dat return finished
This method sends the next DAT packet based on the data in the
        context. It returns a boolean indicating whether the transfer is
        finished.