Catching Save - newbie

Terry Reedy tjreedy at udel.edu
Tue Apr 15 07:55:42 EDT 2003


"Vahur Lokk" <vlokk at hot.ee> wrote in message
news:3e9bd039_2 at news.estpak.ee...
> Hi!
> What I want to do is write a small daemon that can catch Save File
type of
> events in the system and manipulate files being saved.
> Having mostly sorted out the rest of the program I cannot think of a
way to
> catch these saves.
> I must warn that I am complete newb and doing my first steps in
Python (and
> programming overall).

If you want to catch disk writes initiated by other programs, writen
in whatever language, then I believe you have taken on an expert-level
project. Operating systems generally do *not* allow application
programs to catch such low level system events.  One would have to
either patch the existing disk drivers or write a (pseudo)driver that
would sit on top of the existing one.

If you only want to catch file writes in Python programs, you would
only have to patch the Python interpreter on your system.

If you only want to catch file writes in your own programs, you should
simply call your function before or in the process of writing.

myfile.write(manipulate(bytes))

Or derive a myfile class from the builtin file class, give it a save
method, and call that method instead of the write method.

Terry J. Reedy






More information about the Python-list mailing list