root / stats.py

Revision ca5ddc5f5eea62c76b6be75a1fbdedf663dbcfd0, 0.7 kB (checked in by Sebastien Martini <ookoi@…>, 5 months ago)

Flag example files as 'Example'.

  • Property mode set to 100644
Line 
1# Example
2#
3from pyinotify import *
4
5
6class Identity(ProcessEvent):
7
8    def process_default(self, event):
9        # Does nothing, just to demonstrate how stuffs could trivially
10        # be accomplished after having processed statistics.
11        pass
12
13
14def on_loop(notifier):
15    # notifier.proc_fun() is Identity's instance
16    s_inst = notifier.proc_fun().nested_pevent()
17    print repr(s_inst), '\n', s_inst, '\n'
18
19
20wm = WatchManager()
21# Stats is a subclass of ProcessEvent provided by pyinotify
22# for computing basics statistics.
23s = Stats()
24notifier = Notifier(wm, default_proc_fun=Identity(s), read_freq=5)
25wm.add_watch('/tmp/', ALL_EVENTS, rec=True, auto_add=True)
26notifier.loop(callback=on_loop)
Note: See TracBrowser for help on using the browser.