-
-
Save finghine/29e88868fd69e124c1cc5079d33c43ba to your computer and use it in GitHub Desktop.
sync example python 文件同步示例
This file contains 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
from watchdog.observers import Observer | |
from watchdog.events import * | |
import time | |
import sys | |
import subprocess | |
reload(sys) | |
sys.setdefaultencoding('utf-8') | |
class FileEventHandler(FileSystemEventHandler): | |
def __init__(self): | |
FileSystemEventHandler.__init__(self) | |
def on_modified(self, event): | |
filepath = event.src_path | |
if filepath.endswith("xx.txt"): | |
print "sync..." | |
subprocess.call(["sync.bat"]) | |
print "sync over" | |
if __name__ == "__main__": | |
observer = Observer() | |
event_handler = FileEventHandler() | |
observer.schedule(event_handler,"C:/watchdog_test/example",True) | |
observer.start() | |
try: | |
while True: | |
time.sleep(1) | |
except KeyboardInterrupt: | |
observer.stop() | |
observer.join() | |
# save to sync.bat | |
# tar -zcvf - xx.txt | openssl des3 -salt -k 123123 | dd of=xx.txt.des3 | |
# set https_proxy=http://localhost:1080 | |
# gdrive update 0BzqNJHAvF2Hta3dMYXE0NUNuRjQ xx.txt.des3 | |
# gdrive in the dir | |
# need proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment