Skip to main content

This project/library contains common elements related to FTP connections...

Project description

# core-ftp

This project/library provides a comprehensive set of common components and interfaces designed to facilitate and streamline FTP connections, ensuring efficient communication and data transfer…


Python Versions License Pipeline Status Docs Status Security

Installation

Install from PyPI using pip:

pip install core-ftp
uv pip install core-ftp  # Or using UV...

Features

SFTP Client

  • Simplified SFTP connection management with context manager support

  • Multiple authentication methods:

    • Password-based authentication

    • SSH private key authentication with optional passphrase

    • Customizable transport and connection parameters

  • Comprehensive file operations:

    • List files and directories with detailed attributes

    • Upload files from local filesystem or file-like objects

    • Download files to local filesystem

    • Delete files and directories

    • Change and retrieve current working directory

  • Built-in error handling with custom exceptions

  • Automatic resource cleanup

ETL Support

  • Abstract base class for SFTP-based ETL tasks

  • Seamless integration with core-etl framework

  • File filtering capabilities:

    • Filter by file extension

    • Filter by filename prefix

    • Time-based filtering with delay options

  • Optional automatic file cleanup after successful processing

Examples.

from core_ftp.clients.sftp import SftpClient

with SftpClient("test.rebex.net", 22, "demo", "password") as client:
    for x in client.list_files("/"):
        print(x)
from core_ftp.clients.sftp import SftpClient

with SftpClient(
        host="localhost", port=23,
        user="foo", private_key_path="key_path") as client:

    for x in client.list_files("/"):
        print(x)

Local SFTP server using Docker

You can use docker to create an SFTP server to test the client using the functional tests via command python manager.py run-tests –test-type functional –pattern “*.py” and the following docker image: <atmoz/sftp> (https://hub.docker.com/r/atmoz/sftp/).

Authentication via user & password.

docker run \
  -v ./tests/resources/upload:/home/foo/upload:rw \
  -p 22:22 -d atmoz/sftp foo:pass:::upload

Authentication via SSH key.

docker run \
  -v ./tests/resources/ssh_keys/id_rsa.pub:/home/foo/.ssh/keys/id_rsa.pub:ro \
  -v ./tests/resources/upload:/home/foo/upload:rw \
  -p 23:22 -d atmoz/sftp foo::1001

Quick Start

Installation

Install the package:

pip install core-ftp
uv pip install core-ftp     # Or using UV...
pip install -e ".[dev]"     # For development...

Setting Up Environment

  1. Install required libraries:

pip install --upgrade pip
pip install virtualenv
  1. Create Python virtual environment:

virtualenv --python=python3.12 .venv
  1. Activate the virtual environment:

source .venv/bin/activate

Install packages

pip install .
pip install -e ".[dev]"

Check tests and coverage

python manager.py run-tests
python manager.py run-coverage

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: pytest -n auto

  5. Run linting: pylint core_ftp

  6. Run security checks: bandit -r core_ftp

  7. Submit a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

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

core_ftp-2.0.2.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

core_ftp-2.0.2-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file core_ftp-2.0.2.tar.gz.

File metadata

  • Download URL: core_ftp-2.0.2.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for core_ftp-2.0.2.tar.gz
Algorithm Hash digest
SHA256 72aa5e93a99f1a5fc91f0e59b09c67218a170150d41d97831cc4ce846c260023
MD5 c81363165a1924b38157a1ad87bbbd0c
BLAKE2b-256 33f6694c4f8e8a02fecac05ae6e29d717e21adb404ef5924a704dec666b771cb

See more details on using hashes here.

File details

Details for the file core_ftp-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: core_ftp-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for core_ftp-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 28f30efe4d729a53bbe51f47a4c407fa556a8aa7d7cfe0ef8ec526baf0c7f0c5
MD5 1d4113b3737a6b589e4d7939f3922b01
BLAKE2b-256 527f9cb4535b516a293c3f069c67d97968afaee38ffd9adc68d4c2abdbc8fa5a

See more details on using hashes here.

Supported by

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