]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Routine to force files on Feather to match local whenever they are changed
authorCefn Hoile <github.com@cefn.com>
Sat, 17 Feb 2018 01:58:03 +0000 (01:58 +0000)
committerCefn Hoile <github.com@cefn.com>
Sat, 17 Feb 2018 01:58:03 +0000 (01:58 +0000)
python/upload_feather_sync.py [new file with mode: 0644]

diff --git a/python/upload_feather_sync.py b/python/upload_feather_sync.py
new file mode 100644 (file)
index 0000000..b3dac48
--- /dev/null
@@ -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()