summaryrefslogtreecommitdiff
path: root/python2/examples/tutorial_notifier.py
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2009-11-06 01:05:18 +0100
committerSebastien Martini <seb@dbzteam.org>2009-11-06 01:05:18 +0100
commita307369bed619929c3bb5e97a557054947e246e2 (patch)
treed24423271f8f164961a410d63894c7825cdf957c /python2/examples/tutorial_notifier.py
parent6141698fa66aab032f83fa367b735975061504a2 (diff)
downloadpyinotify-a307369bed619929c3bb5e97a557054947e246e2.tar.gz
Modified Pyinotify's hierarchy in order to support differents version
for Python2 and for Python3.
Diffstat (limited to 'python2/examples/tutorial_notifier.py')
-rw-r--r--python2/examples/tutorial_notifier.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/python2/examples/tutorial_notifier.py b/python2/examples/tutorial_notifier.py
new file mode 100644
index 0000000..6ca8e1c
--- /dev/null
+++ b/python2/examples/tutorial_notifier.py
@@ -0,0 +1,23 @@
+# Notifier example from tutorial
+#
+# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
+#
+from pyinotify import WatchManager, Notifier, \
+ ThreadedNotifier, ProcessEvent, IN_DELETE, \
+ IN_CREATE
+
+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 = Notifier(wm, p)
+wdd = wm.add_watch('/tmp', mask, rec=True)
+
+notifier.loop()