/usr/share/doc/python-pyinotify-doc/examples/stats.py is in python-pyinotify-doc 0.9.4-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Example: prints statistics.
#
import pyinotify
class Identity(pyinotify.ProcessEvent):
def process_default(self, event):
# Does nothing, just to demonstrate how stuffs could trivially
# be accomplished after having processed statistics.
print 'Does nothing.'
def on_loop(notifier):
# notifier.proc_fun() is Identity's instance
s_inst = notifier.proc_fun().nested_pevent()
print repr(s_inst), '\n', s_inst, '\n'
wm = pyinotify.WatchManager()
# Stats is a subclass of ProcessEvent provided by pyinotify
# for computing basics statistics.
s = pyinotify.Stats()
notifier = pyinotify.Notifier(wm, default_proc_fun=Identity(s), read_freq=5)
wm.add_watch('/tmp/', pyinotify.ALL_EVENTS, rec=True, auto_add=True)
notifier.loop(callback=on_loop)
|