Created
June 28, 2013 07:25
-
-
Save aoshiman/5883048 to your computer and use it in GitHub Desktop.
pyinotify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Notifier example from tutorial | |
# | |
# See: http://github.com/seb-m/pyinotify/wiki/Tutorial | |
# | |
import pyinotify | |
wm = pyinotify.WatchManager() # Watch Manager | |
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE # watched events | |
class EventHandler(pyinotify.ProcessEvent): | |
def process_IN_CREATE(self, event): | |
print "Creating:", event.pathname | |
def process_IN_DELETE(self, event): | |
print "Removing:", event.pathname | |
handler = EventHandler() | |
notifier = pyinotify.Notifier(wm, handler) | |
wdd = wm.add_watch('/tmp', mask, rec=True) | |
notifier.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment