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/transient_file.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/transient_file.py')
-rw-r--r-- | python2/examples/transient_file.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/python2/examples/transient_file.py b/python2/examples/transient_file.py new file mode 100644 index 0000000..7957717 --- /dev/null +++ b/python2/examples/transient_file.py @@ -0,0 +1,26 @@ +# Example: monitors transient files. +# +# Run this code, then run transient_file.sh in another shell. +from pyinotify import * + +class ProcessTransientFile(ProcessEvent): + + def process_IN_MODIFY(self, event): + # We have explicitely registered for this kind of event. + print '\t', event.pathname, ' -> written' + + def process_default(self, event): + # Implicitely IN_CREATE and IN_DELATE are watched too. You can + # ignore them and provide an empty process_default or you can + # process them, either with process_default or their dedicated + # method (process_IN_CREATE, process_IN_DELETE) which would + # override process_default. + print 'default: ', event.maskname + + +wm = WatchManager() +notifier = Notifier(wm) +# In this case you must give the class object (ProcessTransientFile) +# as last parameter not a class instance. +wm.watch_transient_file('/tmp/test1234', IN_MODIFY, ProcessTransientFile) +notifier.loop() |