pyftpdlib
pyftpdlib copied to clipboard
Provide (optional) stats about a successful transfer
Some FTP servers can return stats about the file transfer that's taking place. For example, one of NASA's anonymous FTPs returns
ftp://lasco6.nascom.nasa.gov/pub/lasco/lastimage/lastimg_C2.gif
226-File successfully transferred
226 0.000 seconds
It'd be great to be able to configure pyftpdlib to do that too, especially considering it can already log statistics about file transfers to a file.
My specific itch comes from the Python requests-ftp project, a basic FTP client, https://github.com/Lukasa/requests-ftp . It uses pyftpdlib for its automated test suite. We recently found out we didn't support multiline FTP responses (it is basic!) and so need a way to reproduce them in tests in order to add support for them.
This seems to be handled by DTPHandler.handle_close, at https://github.com/giampaolo/pyftpdlib/blob/master/pyftpdlib/handlers.py#L861 at the moment.
I'm currently thinking of following the example at http://pythonhosted.org/pyftpdlib/tutorial.html#throttle-bandwidth , but subclassing DTPHandler, modifying how handle_close works (as elegantly as I can) and using my new class as the data channel handler.
Besides my use case - if other FTP servers are able to do this, it seems like a useful - if low priority - feature to add to pyftpdlib.