ftplib - Did the whole file get sent?

Sean DiZazzo half.italian at gmail.com
Sat Oct 23 01:03:38 EDT 2010


Hi,

I have some scripts that send files via ftplib to a client's ftp
site.  The scripts have generally worked great for a few years.
Recently, the client complained that only part of an important  file
made it to their server.  My boss got this complaint and brought it to
my attention.

The first thing I did was track down the specific file transfer in my
logs.  My log showed a success, I told my boss that, but he wasn't
satisfied with my response.  He began asking if there is a record of
the file transfer ack and number of bytes sent for this transfer.  I'm
not keeping a record of that...only success or failure (and some
output)

How can I assure him (and the client) that the transfer completed
successfully like my log shows?  I'm using code similar to the
following:

try:
    ftp = ftplib.FTP(host)
    ftp.login(user, pass)
    ftp.storbinary("STOR " + destfile, open(f.path, 'rb'))
    # log this as success
except:
    # log this as an error

Is ftplib reliable enough to say that if an exception is not thrown,
that the file was transferred in full?

Python 2.4.3 (#1, Sep 17 2008, 16:07:08)
Red Hat Enterprise Linux Server release 5.3 (Tikanga)

Thanks for your thoughts.

~Sean




More information about the Python-list mailing list