Skip to main content

reonnecting_ftp

Continuous integration https://coveralls.io/repos/github/Parquery/reconnecting-ftp/badge.svg?branch=master PyPI - version PyPI - Python Version

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.

Since results need to be atomic, we have to convert the result from ftplib.FTP.mlsd (an iterable of directory entries) to an explicit list of directory entries. While this gives you atomicity (whatever you iterate over will be done in a single connection), all the directory entries need to be stored in memory.

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')

    # iterate over a directory entries atomically
    for name, entry_dict in ftp.mlsd(path=parent_path):
        # do something
        pass

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).

Release files for reconnecting-ftp 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for reconnecting-ftp 1.1.1
File Size Uploaded
reconnecting_ftp-1.1.1.tar.gz 6.0 kB Details

Release files / reconnecting_ftp-1.1.1.tar.gz

Download URL reconnecting_ftp-1.1.1.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
5fb7edb4cbb9a104dbada648b85ee0c08810b998b6867013069a074c90eddf33
BLAKE2b-256 checksum
How to use checksums
1a39a500fa13235419b06ccf9d562bb51da8f4fb2aee61f6cbfc1fd1cbfc68fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

Release history Release notifications | RSS feed

1.1.2

1 release file

This release

1.1.1 This release

1 release file

1.1.0

1 release file

1.0.12

1 release file

1.0.11

1 release file

1.0.10

1 release file

1.0.9

1 release file

1.0.8

1 release file

1.0.7

1 release file

1.0.6

1 release file

1.0.5

1 release file

1.0.4

1 release file

1.0.3

1 release file

1.0.2

1 release file

1.0.1

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page