Hi durumdara, On 2010-08-25 11:18, durumdara wrote: > On aug. 25, 08:07, Stefan Schwarzer <sschwar...@sschwarzer.net> wrote: >> >> The file is 2 GB in size and is fully transferred, without >> blocking or an error message. The status message from the >> server is '226-File successfully transferred\n226 31.760 >> seconds (measured here), 64.48 Mbytes per second', so this >> looks ok, too. >> >> I think your problem is related to the FTP server or its >> configuration. >> >> Have you been able to reproduce the problem? > > Yes. I tried with saving the file, but I also got this error. > but: Total COmmander CAN download the file, and ncftpget also can > download it without problem...
I suppose they do the same as in my former suggestion: "catching" the error and ignoring it. ;-) After all, if I understood you correctly, you get the complete file contents, so with ftplib the download succeeds as well (in a way). You might want to do something like (untested): import os import socket import ftputil def my_download(host, filename): """Some intelligent docstring.""" # Need timestamp to check if we actually have a new # file after the attempted download try: old_mtime = os.path.getmtime(filename) except OSError: old_mtime = 0.0 try: host.download(filename, filename, 'b') except socket.error: is_rewritten = (os.path.getmtime(filename) != old_mtime) # If you're sure that suffices as a test is_complete = (host.path.getsize(filename) == os.path.getsize(filename)) if is_rewritten and is_complete: # Transfer presumably successful, ignore error pass else: # Something else went wrong raise def main(): host = ftputil.FTPHost(...) my_download(host, "large_file") host.close() If you don't want to use an external library, you can use `ftplib.FTP`'s `retrbinary` and check the file size with `ftplib.FTP.size`. This size command requires support for the SIZE command on the server, whereas ftputil parses the remote directory listing to extract the size and so doesn't depend on SIZE support. Stefan -- http://mail.python.org/mailman/listinfo/python-list