blob: e4cb28f97db4ad2aaac2157015a4af858d905050 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# AsyncNotifier example from tutorial
#
# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
#
from pyinotify import WatchManager, AsyncNotifier, \
ThreadedNotifier, ProcessEvent, IN_DELETE, \
IN_CREATE
import asyncore
wm = WatchManager() # Watch Manager
mask = IN_DELETE | IN_CREATE # watched events
class PTmp(ProcessEvent):
def process_IN_CREATE(self, event):
print "Creating:", event.pathname
def process_IN_DELETE(self, event):
print "Removing:", event.pathname
p = PTmp()
notifier = AsyncNotifier(wm, p)
wdd = wm.add_watch('/tmp', mask, rec=True)
asyncore.loop()
|