-
Notifications
You must be signed in to change notification settings - Fork 0
/
watcher.py
53 lines (34 loc) · 998 Bytes
/
watcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
this is the module for weatching the particular folder
'''
import time
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import pudb
class Cswift(FileSystemEventHandler):
# def on_any_event(self,event):
# pu.db
# print "hey event got occured..",event
def on_created(self,event):
pu.db
if(event.is_directory == True):
print "Directory got created",event
else:
print 'file got created',event
def on_modified(self,event):
# pu.db
print "file got modified",event
def on_deleted(self,event):
# pu.db
print "file got deleted",event
if __name__=="__main__":
cswift_handler = Cswift()
observer = Observer()
observer.schedule(cswift_handler,path='/home/cool', recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrrupt:
observer.stop()
observer.join()