sftpsyncer
Synchronise files piecemeal back and forth between a local cache and a remote SFTP server.
Use case
You have a client that sometimes needs to syncronise files to and from an SFTP server.
open() a file whether it’s remote or local. * If the file is available locally, use the local copy. * If the local file doesn’t exist, download it and then use the local copy.
add() files to an upload package, then push() to upload all locally queued files.
This model is simplistic, and will clobber any changes at the other end if a file with the same name exists. If you want to avoid that, you may be better off using Git or the like.
How to use:
import sftpsyncer
from sftpsyncer import syncagent
sagent = syncagent(hostname="remote_sagenth.example.com", host_port="1222",
username="theuser", key_path="/home/theuser/.sagenth/key",
local_root="/tmp/cache", remote_root="/upload_target")
# upload local files
sagent.upload_queue.add("myfile.txt")
sagent.upload_queue.add("docs/readme.txt")
sagent.push() # upload whether or not remote files exist
# auto-get remote files, reading from cache when available
fh1 = sagent.open("myfile.txt") # file is already local, return local fh
fh2 = sagent.open("remote.txt") # file is not local, transfer to local cache, return local fh
# exceptions
try:
fh3 = sagent.open("not_anywhere.txt")
except sftpsyncer.exceptions.FileNotFound as e:
print "File does not exist on local or remote"
try:
fh5 = sagent.open("ssh_server_unavailable.txt")
except sftpsyncer.exceptions.ConnectionError as e:
print "Remote SFTP service appears to be unavailable"
Metadata
Release files for sftpsyncer 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sftpsyncer-0.1.12.tar.gz | 11.7 kB | Without provenance | Details for sftpsyncer-0.1.12.tar.gz |
Release files / sftpsyncer-0.1.12.tar.gz
| Download URL | sftpsyncer-0.1.12.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9ccc3ad0dfe02a4ff53664d65cefe8854dc4c963a99cea9259eb1a7c0d410c52
|
|
BLAKE2b-256 checksum How to use checksums |
c4a1936d21a4077c40bb74b7fd35134b85b9bd9059d65240649468846653ee58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sftpsyncer 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.