Created
July 30, 2019 16:26
-
-
Save gokusenz/52c1b841abb259da6eff2b3e0ea59c0c to your computer and use it in GitHub Desktop.
Rsync example [Python3]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import sys | |
| import os | |
| import re | |
| import subprocess as sub | |
| import requests | |
| def runProcess(exe): | |
| p = sub.Popen(exe, stdout=sub.PIPE, stderr=sub.PIPE) | |
| output, errors = p.communicate() | |
| return output | |
| head = runProcess(['git', 'symbolic-ref', 'HEAD']).strip() | |
| matchObj = re.match('refs/heads/(master)', head.decode("utf-8")) | |
| if matchObj: | |
| print("Sync Master") | |
| os.system("rsync -rloDcv -e 'ssh' . username@[ip-address]:/pathontheserver --exclude=.git --exclude-from=.gitignore --delete") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment