python implementation of NETANTS ?

Tom Babbitt tbabbitt at commspeed.net
Thu Sep 20 03:49:37 CEST 2001


"C.S. Xu" <cxu1 at china.com> wrote in message
news:3a04f47b.0109191616.3cda741a at posting.google.com...
> Hi, is there a way to implement the windows' NETANTS
> downloading program in Python ? I couldn't find how
> to download certain parts (not the whole) of a file
> in the python ftp library. Anybody can give me any
> hints ?
>
> Thanks.

see

11.6.1 FTP Objects

retrbinary(command, callback[, maxblocksize[, rest]])
Retrieve a file in binary transfer mode. command should be an appropriate
"RETR" command, i.e. 'RETR filename'. The callback function is called for
each block of data received, with a single string argument giving the data
block. The optional maxblocksize argument specifies the maximum chunk size
to read on the low-level socket object created to do the actual transfer
(which will also be the largest size of the data blocks passed to callback).
A reasonable default is chosen. rest means the same thing as in the
transfercmd() method.

transfercmd(cmd[, rest])
Initiate a transfer over the data connection. If the transfer is active,
send a "PORT" command and the transfer command specified by cmd, and accept
the connection. If the server is passive, send a "PASV" command, connect to
it, and start the transfer command. Either way, return the socket for the
connection.
If optional rest is given, a "REST" command is sent to the server, passing
rest as an argument. rest is usually a byte offset into the requested file,
telling the server to restart sending the file's bytes at the requested
offset, skipping over the initial bytes. Note however that RFC 959 requires
only that rest be a string containing characters in the printable range from
ASCII code 33 to ASCII code 126. The transfercmd() method, therefore,
converts rest to a string, but no check is performed on the string's
contents. If the server does not recognize the "REST" command, an
error_reply exception will be raised. If this happens, simply call
transfercmd() without a rest argument.

and remember not all servers will allow multiple threads

Tom





More information about the Python-list mailing list