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://aioftp.readthedocs.org)

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.

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


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.2.0.tar.gz (36.4 kB view details)

Uploaded Source

Built Distribution

aioftp-0.2.0-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aioftp-0.2.0.tar.gz
Algorithm Hash digest
SHA256 3aad5f702f44c5ac8c13472fa986cd49a31111cd4535e6c03d3993a95aab2c43
MD5 b147b2846f7fd477f6de3f2f4a0b48e9
BLAKE2b-256 69797363e656829518b11b657a3b9663b0ec54907d024cd794d6d35df75dd559

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aioftp-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ff499460f9c7b4fd56ea1d2c4919011e06b2264d7a924ee94dbff38a03c4bc76
MD5 991d843801af068566b9fc7d8be1e135
BLAKE2b-256 0be1bf199d05703f54f0986f661d46389a9a7e582f0f808b92a9864ea7ae69d4

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