There are several optional solutions, which can be chosen according to the actual situation (running platform, application requirements).
Option 1: Use python to encapsulate the call to the local rsync program If the requirements are relatively simple and there is a local rsync program available on the running platform, you can use the subprocess module to encapsulate the call command to rsync (you can also use the os module to encapsulate, principle are the same as above), for example:
The advantage of this solution is that it is simple to implement and not prone to bugs. The disadvantage is that if you run on a Windows platform, it is more troublesome and you need to install a local rsync program, such as through cygwin.
Option 2, python implementation of rsync protocol: Vivian De Smedt provides a python implementation for rsync on Bitbucket, which is very small and only 15KB. https://bitbucket.org/vds2212/rsync.py
The advantage of this approach is that it is platform-independent and can be used on any platform running python. However, since this is a personal implementation, it may have bugs, be incompatible with standard rsync, and require time to learn how to use the script, etc.
If the purpose is just to call rsync in a python script to complete an automated daily maintenance task on the Linux platform, then the first option is recommended.
Haha, there is no search for related modules.... You can find several by just searching for pypi. https://pypi.python.org/pypi?%3Aaction=search&term=rsync&submit=search
There are several optional solutions, which can be chosen according to the actual situation (running platform, application requirements).
Option 1: Use python to encapsulate the call to the local rsync program
If the requirements are relatively simple and there is a local rsync program available on the running platform, you can use the subprocess module to encapsulate the call command to rsync (you can also use the os module to encapsulate, principle are the same as above), for example:
The advantage of this solution is that it is simple to implement and not prone to bugs. The disadvantage is that if you run on a Windows platform, it is more troublesome and you need to install a local rsync program, such as through cygwin.
Option 2, python implementation of rsync protocol:
Vivian De Smedt provides a python implementation for rsync on Bitbucket, which is very small and only 15KB.
https://bitbucket.org/vds2212/rsync.py
The advantage of this approach is that it is platform-independent and can be used on any platform running python. However, since this is a personal implementation, it may have bugs, be incompatible with standard rsync, and require time to learn how to use the script, etc.
If the purpose is just to call rsync in a python script to complete an automated daily maintenance task on the Linux platform, then the first option is recommended.
Haha, there is no search for related modules....
You can find several by just searching for pypi.
https://pypi.python.org/pypi?%3Aaction=search&term=rsync&submit=search