[Twisted-Python] FTP Client - questions

Renan Mathias Fernandes renan at renanfernandes.org
Thu Mar 18 10:01:20 MDT 2010


Hello,

	I am trying to learn/implement a FTP Client, but I am facing a problem: How can I check if the retrieveFile method has finished downloading a file? As far as I can see, there is no easy way to do this, am I incorrect?
Below is an example of what I am doing to retrieve a file:

class FileReceiver(Protocol):
    """
        Protocol subclass that writes received data to a local file.
    """
    def __init__(self, filename):
        self.file = open(filename, 'wb')

    def dataReceived(self, data):
        self.file.write(data)
                
def connectionMade(ftpClient):
    test = FileReceiver('./testRetrieve.txt')
    
    try:
        ftpClient.retrieveFile('testFile.txt',test)
    except:
        print "Exception -", sys.exc_value
        reactor.stop()


Can anyone shed a light?

Thanks in advance,

Renan Mathias Fernandes








More information about the Twisted-Python mailing list