File: tutorial_notifier.py

package info (click to toggle)
pyinotify 0.8.9-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,076 kB
  • ctags: 5,038
  • sloc: python: 2,094; makefile: 43; sh: 6
file content (21 lines) | stat: -rw-r--r-- 551 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Notifier example from tutorial
#
# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
#
import pyinotify

wm = pyinotify.WatchManager()  # Watch Manager
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE  # watched events

class HandleEvents(pyinotify.ProcessEvent):
    def process_IN_CREATE(self, event):
        print "Creating:", event.pathname

    def process_IN_DELETE(self, event):
        print "Removing:", event.pathname

p = HandleEvents()
notifier = pyinotify.Notifier(wm, p)
wdd = wm.add_watch('/tmp', mask, rec=True)

notifier.loop()