From 7a9e86a76ca7dbee4267a4cbe85cbf05a63f2280 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Fri, 26 Feb 2016 11:26:29 -0500 Subject: [PATCH] added watch --- bin/watch.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bin/watch.py diff --git a/bin/watch.py b/bin/watch.py new file mode 100644 index 0000000..4f759e0 --- /dev/null +++ b/bin/watch.py @@ -0,0 +1,25 @@ +import time +import subprocess +from watchdog.observers import Observer +from watchdog.events import PatternMatchingEventHandler + +class MyHandler(PatternMatchingEventHandler): + patterns=["*.png",] + + def on_created(self, event): + print "yay" + subprocess.Popen(['/bin/bash', '/Users/tyrelsouza/bin/upload_and_copy', event.src_path]) + + +if __name__ == '__main__': + observer = Observer() + observer.schedule(MyHandler(), path='/Users/tyrelsouza/screenshots/') + observer.start() + + try: + while True: + time.sleep(0.1) + except KeyboardInterrupt: + observer.stop() + + observer.join()