ftp client/server for asyncio
Project description
ftp client/server for asyncio. (http://aioftp.readthedocs.org)
Features
Simple.
Extensible.
Proxy via twunnel3.
Goals
Minimum usable core.
Do not use deprecated or overridden commands and features (if possible).
Client use this commands: USER, PASS, ACCT, PWD, CWD, CDUP, MKD, RMD, MLSD, MLST, RNFR, RNTO, DELE, STOR, APPE, RETR, TYPE, PASV, ABOR, QUIT
Server support this commands: USER, PASS, QUIT, PWD, CWD, CDUP, MKD, RMD, MLSD, LIST (but it’s not recommended to use it, cause it has no standard format), MLST, RNFR, RNTO, DELE, STOR, RETR, TYPE (only “I”), PASV, ABOR, APPE
This subsets are enough for 99% of tasks, but if you need something, then you can easily extend current set of commands.
Dependencies
Python 3.4+
docopt (for execution module as script only)
License
aioftp is offered under the Apache 2 license.
Library Installation
pip install aioftp
Getting started
Client example
import asyncio
import aioftp
@asyncio.coroutine
def get_mp3(host, login, password):
ftp = aioftp.Client()
yield from ftp.connect(host)
yield from ftp.login(login, password)
for path, info in (yield from ftp.list(recursive=True)):
if info["type"] == "file" and path.suffix == ".mp3":
yield from ftp.download(path)
loop = asyncio.get_event_loop()
tasks = (
asyncio.async(get_mp3("server1.com", "login", "password")),
asyncio.async(get_mp3("server2.com", "login", "password")),
asyncio.async(get_mp3("server3.com", "login", "password")),
)
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
Server example
import asyncio
import aioftp
loop = asyncio.get_event_loop()
ftp = aioftp.Server()
asyncio.async(ftp.start(None, 8021), loop=loop)
try:
loop.run_forever()
except KeyboardInterrupt:
ftp.close()
loop.run_until_complete(ftp.wait_closed())
loop.close()
Or just use simple server
python -m aioftp --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file aioftp-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: aioftp-0.1.4-py3-none-any.whl
- Upload date:
- Size: 18.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a42e5e165701751df5a41c91366a461684697f167e4cda1b5246d96e9efc3cb |
|
MD5 | 769be84faa186cb0d558154a40d2297d |
|
BLAKE2b-256 | 3b74b138716be01b5adbba7d4297ecdd93a1c577200d33f9ec0ad119d19f7d25 |