[Twisted-Python] How do I upload files using FTPClient?
I am currently designing a code-deploying service, to be used in conjunction with a variety of source control tools. I'm looking to use Twisted in the implementation of the file-transfer mechanism, as Twisted's broad protocol support would make it easy for me to switch from say, FTP to HTTP, or to some custom protocol I roll myself. I've experimented with twisted.protocols.ftp.FTPClient, and the one thing I can't seem to grok is how to perform file uploads. I've read through the code, and it seems that the FTP server class supports RETR and STOR, using DTPFactory, while FTPClient only supports RETR, and implements it independently. Basically, I'm lost as to how to connect FTPClient to DTPFactory, such that I can send files from FTPClient. I just need some pointers on how to accomplish this; it seems like the code is there to do it, but I'm missing the necessary Twisted mindset in this case. Thanks for your help. L. Daniel Burr
On Mon, Jan 06, 2003 at 10:14:18AM -0800, Daniel Burr wrote:
I've experimented with twisted.protocols.ftp.FTPClient, and the one thing I can't seem to grok is how to perform file uploads. I've read through the code, and it seems that the FTP server class supports RETR and STOR, using DTPFactory, while FTPClient only supports RETR, and implements it independently.
Yes, that's my fault. I haven't gotten around to that yet -- I might have a stab at it tonight, it shouldn't actually be that hard. I'll try to make sure I get this done in time for the 1.0.2 release. Let me know if there are any other FTP commands you want implemented -- I've also got MDTM on my todo list, which should be trivial (in fact, the apt-proxy guys have already implemented it! :). The current range of commands more-or-less reflects what I needed for a previous job, and not much more, but I'm happy to add any that someone else finds useful. STOR is definitely useful (and probably the hardest -- the code for uploading from the client isn't really there yet).
Basically, I'm lost as to how to connect FTPClient to DTPFactory, such that I can send files from FTPClient. I just need some pointers on how to accomplish this; it seems like the code is there to do it, but I'm missing the necessary Twisted mindset in this case.
DTPFactory is part of the FTP server, which currently shares no code with the client. The server is desperately in need of a rewrite/refactoring to use twisted.web (so that you can have dynamic resources, and the like). This is on my longer-term todo list... -Andrew.
On Tue, Jan 07, 2003 at 10:37:22AM +1100, Andrew Bennetts wrote:
On Mon, Jan 06, 2003 at 10:14:18AM -0800, Daniel Burr wrote:
I've experimented with twisted.protocols.ftp.FTPClient, and the one thing I can't seem to grok is how to perform file uploads. I've read through the code, and it seems that the FTP server class supports RETR and STOR, using DTPFactory, while FTPClient only supports RETR, and implements it independently.
Yes, that's my fault. I haven't gotten around to that yet -- I might have a stab at it tonight, it shouldn't actually be that hard. I'll try to make sure I get this done in time for the 1.0.2 release.
Just letting you know I haven't forgotten about this, but solving this properly really involves refactoring the mess in FTPClient.retrieve... and if I do that properly, it'll make my planned rewrite of the FTP server alot easier, as it ought to be able to re-use the code. Unfortunately this means it might take a few more days before this happens. -Andrew.
On Tue, Jan 07, 2003 at 10:37:22AM +1100, Andrew Bennetts wrote:
On Mon, Jan 06, 2003 at 10:14:18AM -0800, Daniel Burr wrote:
I've experimented with twisted.protocols.ftp.FTPClient, and the one thing I can't seem to grok is how to perform file uploads. I've read through the code, and it seems that the FTP server class supports RETR and STOR, using DTPFactory, while FTPClient only supports RETR, and implements it independently.
Yes, that's my fault. I haven't gotten around to that yet -- I might have a stab at it tonight, it shouldn't actually be that hard. I'll try to make sure I get this done in time for the 1.0.2 release.
*Ahem*. Ok, so it took slightly longer than that... Thanks to working on this with Chris at PyCon, there is now STOR support for the FTPClient, currently only in CVS, but it will be in the next release. -Andrew.
participants (2)
-
Andrew Bennetts
-
Daniel Burr