[Twisted-Python] Re: Re: Resume FTP file retrieval
Hi Andrew, Thanks very much for your suggestions. I modified my test app to do: size = 10*1024 deferred = ftpclient.queueStringCommand("REST %d" % size) deferred.addCallbacks(setRestSuccess, setRestFailure, callbackArgs=(filename, ftpclient)) In setRestSuccess() I receive the response: ['350 Restarting at 10240. Send STORE or RETRIEVE to initiate transfer.'] Then in setRestSuccess() I do: file_writer = FTPWriterProtocol(filename) deferred = ftpclient.retrieveFile(filename, file_writer) deferred.addCallbacks(downloadSuccess, downloadFail, callbackArgs=(file_writer,), errbackArgs=(file_writer,)) where my protocol is defined as: class FTPWriterProtocol(Protocol): def __init__(self, filename): self.file = open(filename, "ab") def close(self): print 'closing file' self.file.close() def dataReceived(self, data): print "Received %d bytes" % len(data) self.file.write(data) In downloadSuccess() I receive the response: [(1, ["150 Opening BINARY mode data connection for 'SSTEST.TXT' (522000 bytes).", '226 Transfer complete.']), (1, None), (1, None)] However, I actually receive the complete file, and not the partial download I expected. Note: when I use ftplib.FTP.retrbinary() using the "rest" arg (connecting to the same server) I do get the partial download. Any ideas why my Twisted version is not working? regards, Richard Townsend
On Sun, Jan 04, 2004 at 01:37:26PM +0000, Richard Townsend wrote:
Hi Andrew,
Thanks very much for your suggestions. [...]
However, I actually receive the complete file, and not the partial download I expected.
Note: when I use ftplib.FTP.retrbinary() using the "rest" arg (connecting to the same server) I do get the partial download.
Any ideas why my Twisted version is not working?
Glancing at ftplib, the difference is that my suggestion will send REST, PORT/PASV, RETR (in that order), but ftplib does PORT/PASV, REST, RETR. A quick glance at http://cr.yp.to/ftp/retr.html doesn't suggest that this should matter, but this is FTP after all... (and it wouldn't surprise me if different servers behave differently here, too) Looks like FTPClient will need to be changed after all :/ -Andrew.
participants (2)
-
Andrew Bennetts
-
Richard Townsend