summaryrefslogtreecommitdiff
path: root/python2/examples/not_quiet.py
blob: 3b24db22b6d8050d9bacd56ac2b444081e4d229d (plain)
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