summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Martini <seb@dbzteam.org>2010-01-02 19:16:15 +0100
committerSebastien Martini <seb@dbzteam.org>2010-01-02 19:16:15 +0100
commita8a70eeab092b89471435015196894ffb419bd97 (patch)
treee1c50a377709a0627832c1c82dcc6cab2397a0f1
parentb4770e259e71e3e9dc17bf8696e7a82cfdaf98f6 (diff)
downloadpyinotify-a8a70eeab092b89471435015196894ffb419bd97.tar.gz
Updated examples from tutorial.
-rw-r--r--python2/examples/tutorial_asyncnotifier.py13
-rw-r--r--python2/examples/tutorial_notifier.py14
-rw-r--r--python2/examples/tutorial_threadednotifier.py12
3 files changed, 16 insertions, 23 deletions
diff --git a/python2/examples/tutorial_asyncnotifier.py b/python2/examples/tutorial_asyncnotifier.py
index e4cb28f..16e276f 100644
--- a/python2/examples/tutorial_asyncnotifier.py
+++ b/python2/examples/tutorial_asyncnotifier.py
@@ -2,23 +2,20 @@
#
# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
#
-from pyinotify import WatchManager, AsyncNotifier, \
- ThreadedNotifier, ProcessEvent, IN_DELETE, \
- IN_CREATE
import asyncore
+import pyinotify
-wm = WatchManager() # Watch Manager
-mask = IN_DELETE | IN_CREATE # watched events
+wm = pyinotify.WatchManager() # Watch Manager
+mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events
-class PTmp(ProcessEvent):
+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 = PTmp()
-notifier = AsyncNotifier(wm, p)
+notifier = pyinotify.AsyncNotifier(wm, HandleEvents())
wdd = wm.add_watch('/tmp', mask, rec=True)
asyncore.loop()
diff --git a/python2/examples/tutorial_notifier.py b/python2/examples/tutorial_notifier.py
index 6ca8e1c..e807697 100644
--- a/python2/examples/tutorial_notifier.py
+++ b/python2/examples/tutorial_notifier.py
@@ -2,22 +2,20 @@
#
# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
#
-from pyinotify import WatchManager, Notifier, \
- ThreadedNotifier, ProcessEvent, IN_DELETE, \
- IN_CREATE
+import pyinotify
-wm = WatchManager() # Watch Manager
-mask = IN_DELETE | IN_CREATE # watched events
+wm = pyinotify.WatchManager() # Watch Manager
+mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events
-class PTmp(ProcessEvent):
+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 = PTmp()
-notifier = Notifier(wm, p)
+p = HandleEvents()
+notifier = pyinotify.Notifier(wm, p)
wdd = wm.add_watch('/tmp', mask, rec=True)
notifier.loop()
diff --git a/python2/examples/tutorial_threadednotifier.py b/python2/examples/tutorial_threadednotifier.py
index c2aeb04..6fbb4cd 100644
--- a/python2/examples/tutorial_threadednotifier.py
+++ b/python2/examples/tutorial_threadednotifier.py
@@ -2,14 +2,12 @@
#
# See: http://trac.dbzteam.org/pyinotify/wiki/Tutorial
#
-from pyinotify import WatchManager, Notifier, \
- ThreadedNotifier, ProcessEvent, IN_DELETE, \
- IN_CREATE, log
+import pyinotify
-wm = WatchManager() # Watch Manager
-mask = IN_DELETE | IN_CREATE # watched events
+wm = pyinotify.WatchManager() # Watch Manager
+mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events
-class PTmp(ProcessEvent):
+class HandleEvents(pyinotify.ProcessEvent):
def process_IN_CREATE(self, event):
print "Creating:", event.pathname
@@ -18,7 +16,7 @@ class PTmp(ProcessEvent):
#log.setLevel(10)
-notifier = ThreadedNotifier(wm, PTmp())
+notifier = pyinotify.ThreadedNotifier(wm, HandleEvents())
notifier.start()
wdd = wm.add_watch('/tmp', mask, rec=True)