Skip to main content

ftp client/server for asyncio

Project description

https://img.shields.io/travis/pohmelie/aioftp.svg https://img.shields.io/coveralls/pohmelie/aioftp.svg https://img.shields.io/pypi/v/aioftp.svg https://img.shields.io/pypi/pyversions/aioftp.svg

ftp client/server for asyncio (http://pohmelie.github.io/aioftp or http://aioftp.readthedocs.org (no python 3.5))

Features

  • Simple.

  • Extensible.

  • Proxy via twunnel3.

Goals

  • Minimum usable core.

  • Do not use deprecated or overridden commands and features (if possible).

  • Very high level api.

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.

Server benchmark

Compared with pyftpdlib and checked with it’s ftpbench script.

aioftp 0.4.1

$ ./ftpbench -u anonymous -p none -P 8021 -b all
STOR (client -> server)                              146.06 MB/sec
RETR (server -> client)                              273.88 MB/sec
200 concurrent clients (connect, login)                0.36 secs
STOR (1 file with 200 idle clients)                  121.02 MB/sec
RETR (1 file with 200 idle clients)                  274.31 MB/sec
200 concurrent clients (RETR 10.0M file)              16.09 secs
200 concurrent clients (STOR 10.0M file)              19.03 secs
200 concurrent clients (QUIT)                          0.11 secs

pyftpdlib 1.5.0

$ ./ftpbench -u anonymous -p none -P 8021 -b all
STOR (client -> server)                              198.65 MB/sec
RETR (server -> client)                             3361.68 MB/sec
200 concurrent clients (connect, login)                0.09 secs
STOR (1 file with 200 idle clients)                  209.34 MB/sec
RETR (1 file with 200 idle clients)                 3367.59 MB/sec
200 concurrent clients (RETR 10.0M file)               1.04 secs
200 concurrent clients (STOR 10.0M file)               1.98 secs
200 concurrent clients (QUIT)                          0.02 secs

Dependencies

  • Python 3.5

  • docopt (for execution module as script only)

License

aioftp is offered under the WTFPL license.

Library Installation

pip install aioftp

Getting started

Client example

import asyncio
import aioftp


async def get_mp3(host, login, password):

    client = aioftp.Client()
    await client.connect(host)
    await client.login(login, password)
    async for path, info in await client.list(recursive=True):

        if info["type"] == "file" and path.suffix == ".mp3":

            await client.download(path)

    await client.quit()


loop = asyncio.get_event_loop()
tasks = (
    get_mp3("server1.com", "login", "password")),
    get_mp3("server2.com", "login", "password")),
    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()
server = aioftp.Server()
loop.run_until_complete(server.start(None, 8021))
try:

    loop.run_forever()

except KeyboardInterrupt:

    server.close()
    loop.run_until_complete(server.wait_closed())
    loop.close()

Or just use simple server

python -m aioftp --help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aioftp-0.4.1.tar.gz (37.8 kB view details)

Uploaded Source

Built Distribution

aioftp-0.4.1-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file aioftp-0.4.1.tar.gz.

File metadata

  • Download URL: aioftp-0.4.1.tar.gz
  • Upload date:
  • Size: 37.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for aioftp-0.4.1.tar.gz
Algorithm Hash digest
SHA256 549aaf9f085b41d628c295a026a854c5b4f541b89f6fc123806fe7b43bc14964
MD5 1303e5824c211697d6ae23670ef06415
BLAKE2b-256 3f371c57b25a60c37821c687c3c3c21c04f4054633293da0fda0a5e38e761c17

See more details on using hashes here.

File details

Details for the file aioftp-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aioftp-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 385358f8c7b43482bc3269a1bc4774c2b7ef6e883a5ad82d5eaf6dd59bc23f99
MD5 6a421c2a7813513ba7434f0baa5ed484
BLAKE2b-256 d77993c37b42ef8e7b1fe3d09489b66e141780c136b038de89c3ff07a1d8963d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page