Created
December 11, 2010 05:54
-
-
Save laclefyoshi/737187 to your computer and use it in GitHub Desktop.
script using 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
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
# Copyright : (c) SAEKI Yoshiyasu | |
# License : MIT-style license | |
# <http://www.opensource.org/licenses/mit-license.php> | |
# last updated: 2010/12/11 | |
import pyinotify | |
wm = pyinotify.WatchManager() | |
class EventHandler(pyinotify.ProcessEvent): | |
def process_IN_CREATE(self, evt): | |
print "create ", evt.pathname | |
def process_IN_DELETE(self, evt): | |
print "delete ", evt.pathname | |
notifier = pyinotify.Notifier(wm, EventHandler()) | |
mask = pyinotify.IN_DELETE | pyinotify.IN_CREATE | |
watcher = wm.add_watch("TARGET_DIR", mask, rec=True) | |
notifier.loop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment