[ftputil] tell() method for FTPFile objects?
Stefan Schwarzer
sschwarzer at sschwarzer.net
Sat Jan 29 12:26:13 MET 2005
Hello Justin
Summary: _Unless you also need a "seek" method_, I would see if I can
add a "tell" method, but _only_ for binary transfers. Please reply.
On Saturday 29 January 2005 10:41, Justin Ezequiel wrote:
> Excellent module by the way.
Thank you :-)
> I am trying to zip a few files from one FTP server to another and
> was trying to do this using FTPFile objects and zipfile.ZipFile. I
> was trying to get it done without having to download from the
> source server to my local disk, then uploading to the target
> server. However, I am getting the following error as the FTPFile
> object has no tell() method.
>
> Traceback (most recent call last):
> [...]
> AttributeError: '_fileobject' object has no attribute 'tell'
>
> Can this feature be added in the future or am do I just have a bug?
For ASCII transfers, I'm not sure what a "tell" method should return.
For example, assume that CRLF pairs on the server are converted to LF
on the client side. Should "tell" return the position of the "reading
cursor" on the server side or the (less than or equal) position on
the client side?
For binary transfers, there's no such ambiguity. It should be possible
to implement "tell" by storing how many bytes have been read so far.
Note that there will probably never be a "seek" method because the
file object which I get from the socket's "makefile" method has no
"seek" method (you can't reposition on the remote side without
"reading forward" anyway). On the other hand, if someone really needs
"seek" to just satisfy an interface, a "seek" method can probably be
implemented. But it will be very slow (e. g. you have to read
virtually the whole file over the network to position at the file's
last byte).
> In the meantime, I'll be using a temporary local file.
>
> Apologising if this is sent as HTML.
> Cannot find option to explicitly send as Plain Text from walla.com.
At least it arrived as text from the mailing list. I don't know if
Mailman has done any filtering.
Stefan
More information about the ftputil
mailing list