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:
conn = RemoteTransfer(host=host_name, username=user_name, port=22, key=private_key_path)
conn.connect()
conn.list_remote_dir(remote_path)
conn.remote_download(remote_path, local_path, copy_hidden_files=True, copy_symlink_files=True, remove=False)
conn.downloaded_files
conn.remove_downloaded()
conn.disconnect()
To upload to a 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)
conn.disconnect()
License
MIT License
History
0.2.0
0.1.0
- First release, working code