summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-05-16 15:27:18 +0200
committerSebastien Martini <seb@dbzteam.org>2010-05-16 15:27:18 +0200
commit4ff4c0f2bb0092da4655f29fb76c5a74c0bf2071 (patch)
treef8971ddaeecfe530f24ef5a27f95f034590de96c
parentb93192b4de7a13b362c326dccd217c08b08b93a6 (diff)
downloadpyinotify-4ff4c0f2bb0092da4655f29fb76c5a74c0bf2071.tar.gz
Updated examples.
-rw-r--r--python2/examples/daemon.py4
-rw-r--r--python2/examples/loop.py5
2 files changed, 8 insertions, 1 deletions
diff --git a/python2/examples/daemon.py b/python2/examples/daemon.py
index 33281d7..26eaffe 100644
--- a/python2/examples/daemon.py
+++ b/python2/examples/daemon.py
@@ -11,6 +11,8 @@ class Counter(object):
"""
def __init__(self):
self.count = 0
+ def plusone(self):
+ self.count += 1
def on_loop(notifier, counter):
"""
@@ -24,7 +26,7 @@ def on_loop(notifier, counter):
sys.exit(0)
else:
sys.stdout.write("Loop %d\n" % counter.count)
- counter.count += 1
+ counter.plusone()
wm = pyinotify.WatchManager()
notifier = pyinotify.Notifier(wm)
diff --git a/python2/examples/loop.py b/python2/examples/loop.py
index b737c5d..48c81ad 100644
--- a/python2/examples/loop.py
+++ b/python2/examples/loop.py
@@ -2,7 +2,12 @@
#
import pyinotify
+# Instanciate a new WatchManager (will be used to store watches).
wm = pyinotify.WatchManager()
+# Associate this WatchManager with a Notifier (will be used to report and
+# process events).
notifier = pyinotify.Notifier(wm)
+# Add a new watch on /tmp for ALL_EVENTS.
wm.add_watch('/tmp', pyinotify.ALL_EVENTS)
+# Loop forever and handle events.
notifier.loop()