ftplib - 226 message not received

Brendan brendandetracey at yahoo.com
Thu Jan 8 13:32:40 EST 2009


Okay, found it on my own. ftp.voidresp() is what is needed, and it
does _not_ seem to be in the Python documentation for ftplib.

On Jan 8, 1:58 pm, Brendan <brendandetra... at yahoo.com> wrote:
> I am trying to download a file within a very large zipfile. I need two
> partial downloads of the zipfile. The first to get the file byte
> offset, the second to get the file itself which I then inflate.
>
> I am implementing the partial downloads as follows:
>
> con = ftp.transfercmd('RETR ' + filename, rest_offset)  # the data
> socket
> while True:
>     block = con.recv(blocksize)
> # stop transfer while it isn't finished yet
>     if bytes_recv >= buf_length:
>         break
>     elif not block:
>         break
>     buf = ''.join([buf, block])
>     bytes_recv += len(block)
> con.close()
>
> My problem is that even though the socket is closed, I have no way to
> receive the 226 response from server so I can proceed with the next
> download.  Of course I could close the ftp connection entirely and
> open a new one, but I am hoping to avoid doing so.




More information about the Python-list mailing list