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...
Execution Environment
Install libraries
pip install --upgrade pip
pip install virtualenv
Create the Python Virtual Environment.
virtualenv --python={{python-version}} .venv
virtualenv --python=python3.11 .venv
Activate the Virtual Environment.
source .venv/bin/activate
Install required libraries.
pip install .
Check tests and coverage...
python manager.py run-tests
python manager.py run-tests --test-type functional --pattern "*.py"
python manager.py run-coverage
How to Use
Installation...
pip install core-ftp
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)
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