File: not_quiet.py

package info (click to toggle)
pyinotify 0.9.6-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 392 kB
  • sloc: python: 2,498; ansic: 153; makefile: 14; sh: 6
file content (36 lines) | stat: -rw-r--r-- 834 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Example: raise exceptions on errors.
#
# Overrides default behavior and raise exception on add_watch, update_watch
# or rm_watch errors.

import pyinotify

wm = pyinotify.WatchManager()


# default behavior, don't complain but keep trace of error in log and result
r = wm.add_watch(['/tmp', '/tmp-do-not-exist'], pyinotify.ALL_EVENTS)
print r


# quiet=False raise exception
try:
    wm.add_watch(['/tmp', '/tmp-do-not-exist'],
                     pyinotify.ALL_EVENTS, quiet=False)
except pyinotify.WatchManagerError, err:
    print err, err.wmd


# quiet=False raise exception
try:
    wm.update_watch(42, mask=0x42, quiet=False)
except pyinotify.WatchManagerError, err:
    print err, err.wmd


# quiet=False raise exception
try:
    wm.rm_watch(42, quiet=False)
except pyinotify.WatchManagerError, err:
    print err, err.wmd