| Line | |
|---|
| 1 | # Example |
|---|
| 2 | # |
|---|
| 3 | from pyinotify import * |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | class 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 | |
|---|
| 21 | wm = WatchManager() |
|---|
| 22 | notifier = Notifier(wm) |
|---|
| 23 | wm.watch_transient_file('/tmp/test1234', IN_MODIFY, ProcessTransientFile) |
|---|
| 24 | notifier.loop() |
|---|