From: Cefn Hoile Date: Sat, 17 Feb 2018 01:58:03 +0000 (+0000) Subject: Routine to force files on Feather to match local whenever they are changed X-Git-Tag: 0.1.0~4^2~148 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/9193b031bb64be9cd26cfdb3d1a51f224f1f93c0 Routine to force files on Feather to match local whenever they are changed --- diff --git a/python/upload_feather_sync.py b/python/upload_feather_sync.py new file mode 100644 index 0000000..b3dac48 --- /dev/null +++ b/python/upload_feather_sync.py @@ -0,0 +1,29 @@ +# dependencies +# pip3 install watchdog +import time +import subprocess +from watchdog.observers import Observer + +command = 'rsync --prune-empty-dirs --include="*/" --include="*.py" --exclude="*" --recursive --whole-file --verbose --progress ./ /media/cefn/CIRCUITPY' + +syncing = False; +def sync(): + syncing = True + subprocess.run(command, shell=True) + syncing = False + +class ChangeEventHandler: + def dispatch(self, event): + if not syncing: + sync() + +if __name__ == "__main__": + observer = Observer() + observer.schedule(ChangeEventHandler(), ".", recursive=True) + observer.start() + try: + while True: + time.sleep(1) + except KeyboardInterrupt: + observer.stop() + observer.join()