Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

PyRsync is a simple rsync wrapper for python.

License

NotificationsYou must be signed in to change notification settings

lfreist/rsyncer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  1. download this repository
  2. from within this repo runmake install
  3. test installation by importingrsyncer in a python shell

Usage

You can choose between the simpleOne-Function-Call and the more powerfulSyncer utility to run rsync commands usingrsyncer.

TheOne-Function-Call

This is the simplest usage of rsyncer. You can just call thersync function with the necessary arguments to run arsync command. This function will return a boolean indicating if the process finished successfully or not:

fromrsyncer.rsyncimportrsyncsuc=rsync(...)ifsuc:print("rsync run successfully.")else:print("There was an error running rsync.")

The more powerfulSyncer 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.Syncer creates a temporary files in/tmp where 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 aSyncer object and use itsclose() (orexit(), which will kill the rsync process) method inthe end, or you can use aSyncer within awith statement:

fromrsyncerimportrsyncs=rsync.Syncer(...)s.run()s.get_command()s.progress()# and/or other operationss.close()# or s.exit() if you want to kill the rsync process as well
fromrsyncerimportrsyncwithrsync.Syncer(...)ass:s.run()s.get_command()s.progress()# and/or other operations

Examples

As far as possible, we provide aOne-Function-Call and aSyncer implementation for each example.

Syncing a single file

$ rsync /path/to/file /path/to/destination

One-Function-Call

fromrsyncerimportrsyncrsync.rsync(source="/path/to/file",dest="/path/to/destination")

Syncer

fromrsyncerimportrsyncwithrsync.Syncer(source="/path/to/file",dest="/path/to/destination")ass:s.run()

Syncing a directory

$ rsync /path/to/dir /path/to/destination

One-Function-Call

fromrsyncerimportrsyncrsync.rsync(source="/path/to/dir",dest="/path/to/destination")

Syncer

fromrsyncerimportrsyncwithrsync.Syncer(source="/path/to/dir",dest="/path/to/destination")ass:s.run()

Syncing a directory using a remote source

$ rsync -a user@server.org:/path/to/dir /path/to/destination

One-Function-Call

fromrsyncerimportrsyncrsync.rsync(source="/path/to/dir",dest="/path/to/destination",source_ssh="user@server.org")

Syncer

fromrsyncerimportrsyncwithrsync.Syncer(source="/path/to/dir",dest="/path/to/destination",source_ssh="user@server.org")ass:s.run()

Exclude a file

$ rsync /path/to/dir /path/to/destination --exclude /path/to/dir/tmp.txt

One-Function-Call

fromrsyncerimportrsyncrsync.rsync(source="/path/to/dir",dest="/path/to/destination",excludes=["/path/to/dir/tmp.txt"])

Syncer

fromrsyncerimportrsyncwithrsync.Syncer(source="/path/to/dir",dest="/path/to/destination",excludes=["/path/to/dir/tmp.txt"])ass:s.run()

About

PyRsync is a simple rsync wrapper for python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp