Monitoring contents of files/directories?

PythonFileCross PlatformFilesystemsMonitoring

Python Problem Overview


I'm looking for a cross-platform file monitoring python package? I know it is possible to monitor files on windows using pywin32, and there are packages working on Linux/Unix but does anyone know about a cross-platform one?

Python Solutions


Solution 1 - Python

I'm working on an MIT-licensed library that helps Python programs monitor file system events as portably as possible. There are differences that I'm trying to iron out. Highly alpha version at the moment:

Check it out here: http://github.com/gorakhargosh/watchdog/

Patches and contributions are welcome.

Hope it helps. =) Cheers.

Solution 2 - Python

For Unix/Linux based systems, you should use File Alteration Monitor Python bindings to libfam.

For Windows based systems, you should tie into the Win32 API FindFirstChangeNotification and related functions.

As for a cross platform way, I don't know about a good cross platform way. I think it would be best to build a module yourself that works on either OS that uses one of the 2 above methods after detecting what OS it is.

Solution 3 - Python

Also check out this option:

http://pypi.python.org/pypi/watchdog

Was used with a cross-platform app on Windows and OS X.

Solution 4 - Python

I found this link, which talks about your problem. Although it doesn't really provide s solution/library, I think it will help. http://www.stepthreeprofit.com/2008/06/cross-platform-monitoring-of-filesystem.html

I don't think there is a cross-platform one yet, so you might want to roll your own.

I am inexperienced in this area so I am not really sure. I hope this helps.

Note
I stand corrected, gamin is available on cygwin as Adam Bernier pointed out to me in a comment. You may want to research other options on cygwin (if they exist).

Solution 5 - Python

The easiest way on Linux is to use inotifywait (given that your kernel is recent enough). You don't need any special bindings, inotifywait can be customized to print output lines on standard output in any way you want. Look and this question for a good example.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondahpgjgamganView Question on Stackoverflow
Solution 1 - PythonGoraKhargoshView Answer on Stackoverflow
Solution 2 - PythonBrian R. BondyView Answer on Stackoverflow
Solution 3 - Pythonreese.chView Answer on Stackoverflow
Solution 4 - PythonbatbratView Answer on Stackoverflow
Solution 5 - PythonJesperEView Answer on Stackoverflow