rsync wrapper for python
Project description
rsyncer
rsyncer is a simple rsync wrapper for python.
Prerequisites
You need to have an rsync installation on your system and added to your system's path.
Installation
pip install pyrsyncer -U
Development
- download this repository
- from within this repo run
pip install -e . - test installation by importing
rsyncerin a python shell
Usage
You can choose between the simple One-Function-Call and the more powerful Syncer utility to run rsync commands using rsyncer.
The One-Function-Call
This is the simplest usage of rsyncer. You can just call the rsync function with the necessary arguments to run a
rsync command. This function will return a boolean indicating if the process finished successfully or not:
from rsyncer.rsync import rsync
suc = rsync(...)
if suc:
print("rsync run successfully.")
else:
print("There was an error running rsync.")
The more powerful Syncer object
With this utility, you get a larger set of functionalities like
- creating a rsync command
- running a rsync command
- get the current progress of a running rsync process
- ...
Mark:
rsyncer.rsync.Syncercreates a temporary files in/tmpwhere rsync's output is written to. Therefore, aSyncershould be closed when you are done working with it (The rsync subprocess will not be killed).
You can either create a Syncer object and use its close() (or exit(), which will kill the rsync process) method in
the end, or you can use a Syncer within a with statement:
from rsyncer import rsync
s = rsync.Syncer(...)
s.run()
s.get_command()
s.progress()
# and/or other operations
s.close() # or s.exit() if you want to kill the rsync process as well
from rsyncer import rsync
with rsync.Syncer(...) as s:
s.run()
s.get_command()
s.progress()
# and/or other operations
Examples
As far as possible, we provide a One-Function-Call and a Syncer implementation for each example.
Syncing a single file
$ rsync /path/to/file /path/to/destination
One-Function-Call
from rsyncer import rsync
rsync.rsync(source="/path/to/file", dest="/path/to/destination")
Syncer
from rsyncer import rsync
with rsync.Syncer(source="/path/to/file", dest="/path/to/destination") as s:
s.run()
Syncing a directory
$ rsync /path/to/dir /path/to/destination
One-Function-Call
from rsyncer import rsync
rsync.rsync(source="/path/to/dir", dest="/path/to/destination")
Syncer
from rsyncer import rsync
with rsync.Syncer(source="/path/to/dir", dest="/path/to/destination") as s:
s.run()
Syncing a directory using a remote source
$ rsync -a user@server.org:/path/to/dir /path/to/destination
One-Function-Call
from rsyncer import rsync
rsync.rsync(source="/path/to/dir", dest="/path/to/destination", source_ssh="user@server.org")
Syncer
from rsyncer import rsync
with rsync.Syncer(source="/path/to/dir", dest="/path/to/destination", source_ssh="user@server.org") as s:
s.run()
Exclude a file
$ rsync /path/to/dir /path/to/destination --exclude /path/to/dir/tmp.txt
One-Function-Call
from rsyncer import rsync
rsync.rsync(source="/path/to/dir", dest="/path/to/destination", excludes=["/path/to/dir/tmp.txt"])
Syncer
from rsyncer import rsync
with rsync.Syncer(source="/path/to/dir", dest="/path/to/destination", excludes=["/path/to/dir/tmp.txt"]) as s:
s.run()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyrsyncer-0.0.2.tar.gz.
File metadata
- Download URL: pyrsyncer-0.0.2.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
703b2feb4ed5173643b94f33c6761f29d5e8ed2e0d290bb27cd23b481fd60ee9
|
|
| MD5 |
bea32cbb152ed2b9b44b9267382eb445
|
|
| BLAKE2b-256 |
c885fc2a4a454677df409e43efbc6c8edb500f8363f78d47ac045856f4b5381a
|
File details
Details for the file pyrsyncer-0.0.2-py3-none-any.whl.
File metadata
- Download URL: pyrsyncer-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aa3ecc228165964c67ae49989193cab4626aa6d59b14d84c0bde63907d25a38
|
|
| MD5 |
6baabe2b47f10530d1f97da9840b7740
|
|
| BLAKE2b-256 |
fa28eede2d995c68ab94d6052b297a4c9d885e2679b567bcb5b98eedc685a61a
|