SOLVED: Re: ftplib - uploading files using transfercmd?

Eddie Corns eddie at holyrood.ed.ac.uk
Tue Mar 23 10:00:22 EST 2004


Kevin Ollivier <kevino at tulane.edu> writes:

>OK, I finally figured out how to fix my problems with the FTP commands
>being issued in the wrong order - after I've finished uploading the
>file, I have to call ftplib.voidresp().

>Is it possible to get this added as a note to the docs for
>ftplib.transfercmd()?  IIUC, you must always call ftp.voidresp() after
>uploading a file using transfercmd(), and if that's the case, then I
>think it'd be helpful to add a note about it in the ftplib docs so
>that the next person to come along and try something like this doesn't
>run into the same problem. 

It's more complicated than that.  You have to be aware that FTP commands
generate responses, sometimes multiple responses but I think that's so rare
you can ignore it.  Most of the ftplib commands hide this, when I replied to
the first post, I could see that the problem was probably that you weren't
eating your responses, unfortunately I didn't read your message carefully
enough to notice you were calling transfercmd directly (tsk tsk) and hence my
explanation was crap (sorry).  In general you will often need to know what the
response actually is, however neither of the response gathering methods is
exposed, which is probably worth remedying.

Which brings me to the observation in that in such cases it's often best just
to look at the source.  I had a similar problem when trying to turn an FTP
call into a generator but soon noticed all those calls to voidresp.  

However it's probably worth trying to get the documentation augmented to
remind users that transfercmd may need to handle responses and to request that
at least getresp be added as a public interface.  I think there's a
special mail address for such requests but I'm too lazy^H^H^H^Hbusy to look it
up just now.

Eddie



More information about the Python-list mailing list