Skip to main content

sftp_py is a Python package for transferring files between remote and local directories using the paramiko sftp client. After transfer, downloaded/uploaded files can be optionally deleted from the remote/local source directory. Only files (not directories) are transferred - there is no option to recursively transfer nested directories.

Installation

From pypi:

pip3 install sftp_py

From GitHub repository:

git clone https://github.com/AlexOrlek/sftp_py.git
cd sftp_py
pip3 install .

Options and usage

sftp_py can be used within a Python script as follows:
from sftp_py.transfer import RemoteTransfer
conn = RemoteTransfer([arguments...])

To download from a remote server:

# Establish connection and download files. 
# local_path must be a directory
# remote_path can be a single file or a directory containing files to be transferred

conn = RemoteTransfer(host=host_name, username=user_name, port=22, key=private_key_path)
conn.connect()
conn.list_remote_dir(remote_path)  # inspect directory contents
conn.remote_download(remote_path, local_path, copy_hidden_files=True, copy_symlink_files=True, remove=False)

# hidden files (.*) and symlink files are copied by default
# remove=True: downloaded files are removed immediately after transfer
# remove=False (default): downloaded files are recorded and can be removed later...

conn.downloaded_files  # conn.downloaded_files records list of downloaded filenames
conn.remove_downloaded()  # remove downloaded files

# Disconnect once finished

conn.disconnect()

To upload to a server:

# Code for uploading to a remote server is similar to code for downloading from a remote server...

conn = RemoteTransfer(host=host_name, username=user_name, port=22, key=private_key_path)
conn.connect()
conn.remote_upload(remote_path, local_path, remove=True)  # upload and remove uploaded files from local_path
conn.disconnect()

License

MIT License

History

0.2.0

  • First release on PyPI

0.1.0

  • First release, working code

Metadata

Release files for sftp-py 0.2.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 sftp-py 0.2.1
File Size Uploaded
sftp_py-0.2.1.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sftp-py 0.2.1
File Interpreter ABI Platform
sftp_py-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / sftp_py-0.2.1.tar.gz

Download URL sftp_py-0.2.1.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4bb99c6c71ee513d37a09e610e6d48f9519e645b740b2b32449769b8984f2dac
BLAKE2b-256 checksum
How to use checksums
658afb89a816ed2e2af183d0011f44dd99c3dd95c553bfdc1d500b7d19ad67ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.6rc1

Release files / sftp_py-0.2.1-py3-none-any.whl

Download URL sftp_py-0.2.1-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b835915c597d51cc54d75f8b86c21fc980567b9a0d6db75fa98fc7bbc72199af
BLAKE2b-256 checksum
How to use checksums
f4cda6c9b68f8259595219344f44b89e069dadf9d33f305be15d60947de4217a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.6.6rc1

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

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