forked from zeitkunst/quill_utils
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathtest_continuous.py
More file actions
executable file
·40 lines (29 loc) · 868 Bytes
/
test_continuous.py
File metadata and controls
executable file
·40 lines (29 loc) · 868 Bytes
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
#!/usr/bin/env python
import doctest
import sys
import time
import os
sys.path.append('src')
import os
from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent
class PTmp(ProcessEvent):
def process_IN_CLOSE_WRITE(self, event):
print '='*79
print 'Wrote: %s' % os.path.join(event.path, event.name)
time.sleep(0.5)
os.system('./test.py')
def inotify_watch():
wm = WatchManager()
mask = EventsCodes.ALL_FLAGS['IN_CLOSE_WRITE']
wdd = wm.add_watch('src', mask, rec=True)
notifier = Notifier(wm, PTmp())
while True:
try:
notifier.process_events()
if notifier.check_events():
notifier.read_events()
except KeyboardInterrupt:
notifier.stop()
break
if __name__ == '__main__':
inotify_watch()