added watch
This commit is contained in:
parent
3d4d53a881
commit
7a9e86a76c
25
bin/watch.py
Normal file
25
bin/watch.py
Normal file
@ -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()
|
Loading…
Reference in New Issue
Block a user