Skip to main content

Reconnecting FTP client

Project description

reonnecting_ftp

reconnecting_ftp provides a FTP client which wraps ftplib.FTP. It reconnects automatically to the server if it was disconnected, and remembers the last recorded working directory.

We found reconnection to be particularly important in scripts which run for a long time, and need to repeatedly iterate over the files on the FTP server.

Additionally, we provide an implementation of mlst FTP command which is missing in the original ftplib.FTP client.

Usage

import reconnecting_ftp

with reconnecting_ftp.Client(hostname="some-host.com", port=21, user="some-user", password="some-password") as ftp:
    # change working directory
    ftp.cwd(dirname='/some-dir/some-subdir')

    # you can execute here all the commands as provided in ftplib.FTP. If the connection failed, the command will
    # be retried while it succeeds or the maximum number of retries haven been exhausted..

    # MLST the file
    pth, entry = ftp.mlst(filename='some-file.txt')

Installation

  • Create a virtual environment:

python3 -m venv venv3
  • Activate it:

source venv3/bin/activate
  • Install reconnecting_ftp with pip:

pip3 install reconnecting_ftp

Development

  • Check out the repository.

  • In the repository root, create the virtual environment:

python3 -m venv venv3
  • Activate the virtual environment:

source venv3/bin/activate
  • Install the development dependencies:

pip3 install -e .[dev]
  • We provide a set of pre-commit checks that lint and check code for formatting and runs unit tests. Run them locally from an activated virtual environment with development dependencies:

./precommit.py
  • The pre-commit script can also automatically format the code:

./precommit.py  --overwrite

Versioning

We follow Semantic Versioning. The version X.Y.Z indicates:

  • X is the major version (backward-incompatible),

  • Y is the minor version (backward-compatible), and

  • Z is the patch version (backward-compatible bug fix).

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

reconnecting_ftp-1.0.7.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file reconnecting_ftp-1.0.7.tar.gz.

File metadata

File hashes

Hashes for reconnecting_ftp-1.0.7.tar.gz
Algorithm Hash digest
SHA256 6838fc2e8c65bd56dcc06c1c48bdaa2e209dceb8cc6c9c8ac58ab2cb7c9e5d82
MD5 f8b3833cf5c09e876b53fa4b118e6dcd
BLAKE2b-256 40d5de3513e0f8f671b1d35832850f326f179d05545acd3b6bf500c35c27043e

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