Created
May 8, 2012 20:51
-
-
Save AyumuKasuga/2639168 to your computer and use it in GitHub Desktop.
filewatcher
This file contains hidden or 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
#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