| Line | |
|---|
| 1 | # Example |
|---|
| 2 | # |
|---|
| 3 | |
|---|
| 4 | # Overrides default behavior and raise exception on add_watch, update_watch, |
|---|
| 5 | # rm_watch errors. |
|---|
| 6 | |
|---|
| 7 | import pyinotify |
|---|
| 8 | |
|---|
| 9 | wm = pyinotify.WatchManager() |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | # default behavior, don't complain but keep trace of error in log and result |
|---|
| 13 | r = wm.add_watch(['/tmp', '/tmp-do-not-exist'], pyinotify.ALL_EVENTS) |
|---|
| 14 | print r |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | # quiet=False raise exception |
|---|
| 18 | try: |
|---|
| 19 | wm.add_watch(['/tmp', '/tmp-do-not-exist'], |
|---|
| 20 | pyinotify.ALL_EVENTS, quiet=False) |
|---|
| 21 | except pyinotify.WatchManagerError, err: |
|---|
| 22 | print err, err.wmd |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | # quiet=False raise exception |
|---|
| 26 | try: |
|---|
| 27 | wm.update_watch(42, mask=0x42, quiet=False) |
|---|
| 28 | except pyinotify.WatchManagerError, err: |
|---|
| 29 | print err, err.wmd |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | # quiet=False raise exception |
|---|
| 33 | try: |
|---|
| 34 | wm.rm_watch(42, quiet=False) |
|---|
| 35 | except pyinotify.WatchManagerError, err: |
|---|
| 36 | print err, err.wmd |
|---|