written improvement on ftplib.FTP(); relevant questions

Beeyah dbickett at gmail.com
Mon Aug 2 03:59:58 CEST 2004


in my inability to find a working ftp program for my mac, i decided to
write one in python. i wrote a class (link at end of post) that
inherited ftplib.FTP and made the process slightly less involved, but
it brought up a few questions:

using the sendcmd() method to do a simple "LIST" command returns an
error explaining that a data connection could not be opened, just as
if you connected to a ftp server using telnet. so, you use the method
retrlines() with "LIST", and everything's fine. the whole module, in
my opinion, seems like a piece of work. every method gives the
appearance of a workaround. i get the impression it would be
enormously easier to manipulate and comprehend if you simply wrote it
on your own with sockets.

so what i'm saying is i want to write my own ftp class, but i don't
know how to handle the two seperate data/command sockets. i started to
read the rfc, but i'm so sick of those things lately. if it isn't a
simple explanation, could someone point me to an appropriate document,
or the relevant page of the rfc, that will explain the process of the
command connection versus the data connection in general programatic
terms? I'd appreciate that.

anyway, if anyone's interested, i'll link to the class i wrote. it
uses a queue to store messages from the server and general program
messages, with the intention of having a seperate thread to sit and
interpret/output. in addition, the class is intentionally completely
detached from the fate of the program, that way it could be more
universal. with that in mind, when something fatal involving the
connection has occured, it pushes a simple "exit" string to the queue
-- one that could be changed to a numeric representation of an error
message or whatever, to be "interpreted" so to speak. its right here:

http://216.67.238.18/~bar/misc/BetterFTP.py

Beeyah



More information about the Python-list mailing list