root / transient_file.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 ProcessTransientFile(ProcessEvent):
7
8    def process_IN_MODIFY(self, event):
9        # We have explicitely registered for this kind of event.
10        print '\t', event.pathname, ' -> written'
11
12    def process_default(self, event):
13        # Implicitely IN_CREATE and IN_DELATE are watched too. You can
14        # ignore them and provide an empty process_default or you process them,
15        # either with process_default or their dedicated method
16        # (process_IN_CREATE, process_IN_DELETE), which will override
17        # process_default.
18        print 'default: ', event.maskname
19
20
21wm = WatchManager()
22notifier = Notifier(wm)
23wm.watch_transient_file('/tmp/test1234', IN_MODIFY, ProcessTransientFile)
24notifier.loop()
Note: See TracBrowser for help on using the browser.