Skip to content

Instantly share code, notes, and snippets.

@AyumuKasuga
Created May 8, 2012 20:51
Show Gist options
  • Save AyumuKasuga/2639168 to your computer and use it in GitHub Desktop.
Save AyumuKasuga/2639168 to your computer and use it in GitHub Desktop.
filewatcher
#coding: utf-8
import pyinotify
import os
class action(pyinotify.ProcessEvent):
def process_IN_MODIFY(self, event):
l = open(os.path.join(event.path, event.name)).readlines()[-1]
#print os.path.join(event.path, event.name), l
print l
wm = pyinotify.WatchManager()
a = action()
notifier = pyinotify.Notifier(wm, a)
mask = pyinotify.IN_MODIFY
wdd = wm.add_watch('.', mask, rec=True, auto_add=True)
notifier.loop()
#while True: # loop forever
# try:
# notifier.process_events()
# if notifier.check_events():
# notifier.read_events()
# print dir(notifier)
# except KeyboardInterrupt:
# notifier.stop()
# break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment