views:

1995

answers:

3

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

+1  A: 

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).

batbrat
Seems to be some good feedback for Gamin on Linux. FWIW, Gamin is listed in cygwin packages: http://cygwin.com/packages/
Adam Bernier
Ah! cygwin! I didn't think of that. I stand corrected.
batbrat
+4  A: 

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.

Brian R. Bondy
Can you provide links? That would make this answer that much greater.
Matt Joiner
@Matt: Links for what? There are links.
Brian R. Bondy
Nevermind, I added them.
Matt Joiner
@Matt: Oops I see, thanks.
Brian R. Bondy
Could you explain how to use the W32 API in an example... because I don't get that...
wishi
A: 

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.

JesperE
He specifically mentioned cross platform. inotifywait is only for linux
Quintin Par