reconnecting-ftp


Namereconnecting-ftp JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/Parquery/reconnecting-ftp
SummaryReconnecting FTP client
upload_time2024-09-16 12:11:30
maintainerNone
docs_urlNone
authorMarko Ristin
requires_pythonNone
licenseNone
keywords ftplib reconnect retry robust ftp client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            reonnecting_ftp
===============

.. image:: https://github.com/Parquery/reconnecting-ftp/workflows/CI/badge.svg
    :target: https://github.com/Parquery/reconnecting-ftp/actions?query=workflow%3ACI
    :alt: Continuous integration

.. image:: https://coveralls.io/repos/github/Parquery/reconnecting-ftp/badge.svg?branch=master
    :target: https://coveralls.io/github/Parquery/reconnecting-ftp

.. image:: https://badge.fury.io/py/reconnecting-ftp.svg
    :target: https://badge.fury.io/py/reconnecting-ftp
    :alt: PyPI - version

.. image:: https://img.shields.io/pypi/pyversions/reconnecting-ftp.svg
    :alt: 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
=====
.. code-block:: python

    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:

.. code-block:: bash

    python3 -m venv venv3

* Activate it:

.. code-block:: bash

    source venv3/bin/activate

* Install reconnecting_ftp with pip:

.. code-block:: bash

    pip3 install reconnecting_ftp

Development
===========

* Check out the repository.

* In the repository root, create the virtual environment:

.. code-block:: bash

    python3 -m venv venv3

* Activate the virtual environment:

.. code-block:: bash

    source venv3/bin/activate

* Install the development dependencies:

.. code-block:: bash

    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:

.. code-block:: bash

    ./precommit.py

* The pre-commit script can also automatically format the code:

.. code-block:: bash

    ./precommit.py  --overwrite

Versioning
==========
We follow `Semantic Versioning <http://semver.org/spec/v1.0.0.html>`_. 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).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Parquery/reconnecting-ftp",
    "name": "reconnecting-ftp",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "ftplib reconnect retry robust ftp client",
    "author": "Marko Ristin",
    "author_email": "marko@ristin.ch",
    "download_url": "https://files.pythonhosted.org/packages/92/c0/f8b1c3e6b609d25adec4c0bbb2d8592051ef83405a868ded3679b2af5588/reconnecting_ftp-1.1.2.tar.gz",
    "platform": null,
    "description": "reonnecting_ftp\n===============\n\n.. image:: https://github.com/Parquery/reconnecting-ftp/workflows/CI/badge.svg\n    :target: https://github.com/Parquery/reconnecting-ftp/actions?query=workflow%3ACI\n    :alt: Continuous integration\n\n.. image:: https://coveralls.io/repos/github/Parquery/reconnecting-ftp/badge.svg?branch=master\n    :target: https://coveralls.io/github/Parquery/reconnecting-ftp\n\n.. image:: https://badge.fury.io/py/reconnecting-ftp.svg\n    :target: https://badge.fury.io/py/reconnecting-ftp\n    :alt: PyPI - version\n\n.. image:: https://img.shields.io/pypi/pyversions/reconnecting-ftp.svg\n    :alt: PyPI - Python Version\n\n\nreconnecting_ftp provides a FTP client which wraps ftplib.FTP. It reconnects automatically to the server if it was\ndisconnected, and remembers the last recorded working directory.\n\nWe found reconnection to be particularly important in scripts which run for a long time, and need to repeatedly iterate\nover the files on the FTP server.\n\nSince results need to be atomic, we have to convert the result from\n``ftplib.FTP.mlsd`` (an iterable of directory entries) to an explicit list of directory entries. While this gives you\natomicity (whatever you iterate over will be done in a single connection), all the directory entries need to be stored\nin memory.\n\nAdditionally, we provide an implementation of ``mlst`` FTP command which is missing in the original ``ftplib.FTP``\nclient.\n\n\n\nUsage\n=====\n.. code-block:: python\n\n    import reconnecting_ftp\n\n    with reconnecting_ftp.Client(hostname=\"some-host.com\", port=21, user=\"some-user\", password=\"some-password\") as ftp:\n        # change working directory\n        ftp.cwd(dirname='/some-dir/some-subdir')\n\n        # you can execute here all the commands as provided in ftplib.FTP. If the connection failed, the command will\n        # be retried while it succeeds or the maximum number of retries haven been exhausted..\n\n        # MLST the file\n        pth, entry = ftp.mlst(filename='some-file.txt')\n\n        # iterate over a directory entries atomically\n        for name, entry_dict in ftp.mlsd(path=parent_path):\n            # do something\n            pass\n\nInstallation\n============\n\n* Create a virtual environment:\n\n.. code-block:: bash\n\n    python3 -m venv venv3\n\n* Activate it:\n\n.. code-block:: bash\n\n    source venv3/bin/activate\n\n* Install reconnecting_ftp with pip:\n\n.. code-block:: bash\n\n    pip3 install reconnecting_ftp\n\nDevelopment\n===========\n\n* Check out the repository.\n\n* In the repository root, create the virtual environment:\n\n.. code-block:: bash\n\n    python3 -m venv venv3\n\n* Activate the virtual environment:\n\n.. code-block:: bash\n\n    source venv3/bin/activate\n\n* Install the development dependencies:\n\n.. code-block:: bash\n\n    pip3 install -e .[dev]\n\n* We provide a set of pre-commit checks that lint and check code for formatting and runs unit tests. Run them locally\n  from an activated virtual environment with development dependencies:\n\n.. code-block:: bash\n\n    ./precommit.py\n\n* The pre-commit script can also automatically format the code:\n\n.. code-block:: bash\n\n    ./precommit.py  --overwrite\n\nVersioning\n==========\nWe follow `Semantic Versioning <http://semver.org/spec/v1.0.0.html>`_. The version X.Y.Z indicates:\n\n* X is the major version (backward-incompatible),\n* Y is the minor version (backward-compatible), and\n* Z is the patch version (backward-compatible bug fix).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Reconnecting FTP client",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/Parquery/reconnecting-ftp"
    },
    "split_keywords": [
        "ftplib",
        "reconnect",
        "retry",
        "robust",
        "ftp",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92c0f8b1c3e6b609d25adec4c0bbb2d8592051ef83405a868ded3679b2af5588",
                "md5": "526a89290d631eaa5ff963735b9d79ed",
                "sha256": "b2e60716cd0e12467de3493957c4fb649fb2daa49a2d4b64f42cb36e7c0574f6"
            },
            "downloads": -1,
            "filename": "reconnecting_ftp-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "526a89290d631eaa5ff963735b9d79ed",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7808,
            "upload_time": "2024-09-16T12:11:30",
            "upload_time_iso_8601": "2024-09-16T12:11:30.287460Z",
            "url": "https://files.pythonhosted.org/packages/92/c0/f8b1c3e6b609d25adec4c0bbb2d8592051ef83405a868ded3679b2af5588/reconnecting_ftp-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-16 12:11:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Parquery",
    "github_project": "reconnecting-ftp",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "reconnecting-ftp"
}
        
Elapsed time: 0.33782s