Skip to content

Instantly share code, notes, and snippets.

@laclefyoshi
Created December 11, 2010 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laclefyoshi/737187 to your computer and use it in GitHub Desktop.
Save laclefyoshi/737187 to your computer and use it in GitHub Desktop.
script using pyinotify
#!/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