Skip to content

Commit

Permalink
Updated examples from tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
seb-m committed Jan 2, 2010
1 parent b4770e2 commit a8a70ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
13 changes: 5 additions & 8 deletions python2/examples/tutorial_asyncnotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
14 changes: 6 additions & 8 deletions python2/examples/tutorial_notifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
12 changes: 5 additions & 7 deletions python2/examples/tutorial_threadednotifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -18,7 +16,7 @@ def process_IN_DELETE(self, event):


#log.setLevel(10)
notifier = ThreadedNotifier(wm, PTmp())
notifier = pyinotify.ThreadedNotifier(wm, HandleEvents())
notifier.start()

wdd = wm.add_watch('/tmp', mask, rec=True)
Expand Down

0 comments on commit a8a70ee

Please sign in to comment.