john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

pyinotify watch directory all events

# http://seb-m.github.io/pyinotify/
import pyinotify
watch_dir = '/home/ubuntu/Dropbox/controls'

class Identity(pyinotify.ProcessEvent):
    def process_default(self, event):
        print 'Does nothing.'

def on_loop(notifier):
    s_inst = notifier.proc_fun().nested_pevent()
    print repr(s_inst), '\n', s_inst, '\n'


wm = pyinotify.WatchManager()
s = pyinotify.Stats()
notifier = pyinotify.Notifier(wm, default_proc_fun=Identity(s), read_freq=5)
wm.add_watch(watch_dir, pyinotify.ALL_EVENTS, rec=True, auto_add=True)
notifier.loop(callback=on_loop)

  • « exceptions try except Exception as error traceback stack trace
  • Services disable startup debian ubuntu rcconf dialog init »

Published

Oct 29, 2013

Category

python

~35 words

Tags

  • all 7
  • directory 13
  • events 1
  • pyinotify 1
  • python 180
  • watch 2