diff options
| author | Sebastien Martini <seb@dbzteam.org> | 2009-11-06 01:05:18 +0100 |
|---|---|---|
| committer | Sebastien Martini <seb@dbzteam.org> | 2009-11-06 01:05:18 +0100 |
| commit | a307369bed619929c3bb5e97a557054947e246e2 (patch) | |
| tree | d24423271f8f164961a410d63894c7825cdf957c /python2/examples/exclude.py | |
| parent | 6141698fa66aab032f83fa367b735975061504a2 (diff) | |
| download | pyinotify-a307369bed619929c3bb5e97a557054947e246e2.tar.gz | |
Modified Pyinotify's hierarchy in order to support differents version
for Python2 and for Python3.
Diffstat (limited to 'python2/examples/exclude.py')
| -rw-r--r-- | python2/examples/exclude.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/python2/examples/exclude.py b/python2/examples/exclude.py new file mode 100644 index 0000000..850dbfe --- /dev/null +++ b/python2/examples/exclude.py @@ -0,0 +1,27 @@ +# Example: excludes items from being monitored. +# +import pyinotify +import os + +excl_file = os.path.join(os.getcwd(), 'exclude.patterns') + +wm = pyinotify.WatchManager() +notifier = pyinotify.Notifier(wm) + + +### Method 1: +# Exclude filter object +excl = pyinotify.ExcludeFilter({excl_file: ('excl_lst1', 'excl_lst2')}) +# Add watches +wm.add_watch(['/etc/*', '/var'], pyinotify.ALL_EVENTS, + rec=True, do_glob=True, exclude_filter=excl) + + +### Method 2 (Equivalent) +wm.add_watch('/etc/*', pyinotify.ALL_EVENTS, rec=True, do_glob=True, + exclude_filter=pyinotify.ExcludeFilter({excl_file:('excl_lst1',)})) +wm.add_watch('/var', pyinotify.ALL_EVENTS, rec=True, + exclude_filter=pyinotify.ExcludeFilter({excl_file:('excl_lst2',)})) + + +notifier.loop() |
