A python wrapper of rsync that yields stats updates.
Project description
A library for using rsync from python.
from pathlib import Path
from rsyncwrap import rsyncwrap
source = Path('/the_source')
dest = Path('/the_destination')
for update in rsyncwrap(source, dest):
print(update)
rsyncwrap
yields progress updates via Stats
objects that have the following properties:
in_progress_stats
: An instance ofTransferStats
(see below for a description).transferring_path
: An instance ofpathlib.Path
that indicates the path that is currently transferring.last_completed_path
: An instance ofpathlib.Path
that indicates the last path to finish transferring.completed_paths
: A dictionary withpathlib.Path
keys andTransferStats
objects as values. The value for each key is the stats for that completed transfer.last_completed_path_stats
: An instance ofTransferStats
for the last completed transfer.total_transferred
: The total bytes transferred so far. Does not include bytes already at the destination when the transfer started.raw_output
: A list of lines we got from the underlying rsync command. Useful for debugging during development.
TransferStats
objects look like this:
transferred_bytes
: The total bytes transferred for the current line of rsync output.percent
: The percent complete for the current file being transferred.time
: Rsync's estimated time for the current file being transferred.transfer_rate
: Rsync's value for the current transfer in bytes.transfer_rate_unit
: Rsync's outputted transfer rate unit. e.g. "MB/s"is_completed_stats
: Is this the stats for a completed file transfer?
Notes about how we use rsync:
- We call rsync with the
-a
option. This means it's recursive and preserves everything except hard links. - This early version only supports transferring the
source
directory into the destination directory. In other words, in the above example we'd end up with/the_destination/the_source
. - Of course, since this is rsync, we only transfer changed bytes and this means it's a resumable process.
- In my testing rsync yields a stats update about once a second, so that's how often we yield them to the caller.
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
rsyncwrap-0.1.1.tar.gz
(7.4 kB
view details)
Built Distribution
File details
Details for the file rsyncwrap-0.1.1.tar.gz
.
File metadata
- Download URL: rsyncwrap-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | efa04d60dbe3615d4472aa3b3a200d21d74ddbb943a4b8eafe5caf0b79beb8ff |
|
MD5 | 8c1c5644cee3e9d64a293356a55edd30 |
|
BLAKE2b-256 | 3147c41bc3b45d341660d00c225b8abe206074d7268974cba77134ba4be02123 |
File details
Details for the file rsyncwrap-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: rsyncwrap-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d738f5abe7af2086d180205b8376a5463e93a0d872b634239cf8003eb358ea |
|
MD5 | 8951f176899b40ccd8c273c613cbedb5 |
|
BLAKE2b-256 | d525c1508a565783a23db9793249261bb4687dd7016067fe827b62e955b44c6a |