Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import os
- import subprocess
- # Set sync source & destination
- source_path = "temp/a"
- dest_path = "temp/b"
- # Sync: source_path -> mountpoint
- if sys.platform.startswith('win'):
- # Windows: Robocopy.exe
- cmd = [
- 'Robocopy.exe',
- os.path.abspath(source_path),
- os.path.abspath(dest_path),
- '/MIR', '/Z', '/W:5',
- ]
- else:
- # Linux: rsync
- cmd = [
- 'rsync',
- '-aIvzh', '--delete',
- "{}/".format(os.path.abspath(source_path)),
- "{}/".format(os.path.abspath(dest_path)),
- ]
- # Create & Run process
- process = subprocess.Popen(
- cmd, shell=True,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- )
- for line in process.stdout:
- process.poll()
- print(line.decode().rstrip('\n'))
- process.wait()
- print("Process finished with return code: {}".format(process.returncode))
Add Comment
Please, Sign In to add comment