DirWatch is a small python module that attempts to provide a non-polling filesystem monitor. It aims to listen for file system events in nominated directories.
File system events can include:
- File creation,
- File delete,
- File modification.
The events provided may depend on the host operating system.
Initially support is aimed at Windows machines, but this may be extended to other platforms as need arises.
The source code lives at:
You will need to have the pywin32 extensions installed, and at least python 2.6.
The demo and tests currently need at least python 2.7 to run. If there's any interest, I'll happily backport or accept patches.
Grab a copy of the source code, and run the usual:
python setup.py install
A small test module is included (in the dirwatch/test directory). It currently assumes the dirwatch module is importable.
Dirwatch has grown a bit too organically, out of small experiments with ReadDirectoryChangesW(), and is still at quite a "works for me" level of quality. Hopefully this will improve with time.
That said, feel free to point out any problems, or give suggestions on how to do things better.
Either log the bug/idea with the issue tracker, send a bitbucket pull request for your changes, or just shoot me an email.
If what we see here doesn't fit your tastes, you might want to look over at:
That is a python library which provides a similar service, but does it via a proper C extension, and implementing a well-defined, known interface (the FileSystemWatcher from C#).
If that library was available when I began writing dirwatch, I probably wouldn't have started. :) But as it didn't and I did, I offer up dirwatch in case it helps solve, or at least provide a different angle, on any shared problems.