From a307369bed619929c3bb5e97a557054947e246e2 Mon Sep 17 00:00:00 2001 From: Sebastien Martini Date: Fri, 6 Nov 2009 01:05:18 +0100 Subject: Modified Pyinotify's hierarchy in order to support differents version for Python2 and for Python3. --- python2/examples/transient_file.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 python2/examples/transient_file.py (limited to 'python2/examples/transient_file.py') 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() -- cgit v1.2.1