dotfiles/home/bin/watch.py

26 lines
631 B
Python
Raw Normal View History

2016-02-26 16:26:29 +00:00
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()