26

Could not find anything in python core to do this. Can anyone recommend a library or "battery" to do this? Ideally I would like this to be portable but it's OK if it is available only for Unix (my server).

martineau
  • 112,593
  • 23
  • 157
  • 280
Gnu Engineer
  • 1,475
  • 2
  • 13
  • 15
  • Some more answers here: http://stackoverflow.com/questions/182197/how-do-i-watch-a-file-for-changes-using-python – Spaceghost Jan 16 '11 at 22:42

3 Answers3

12

On Linux, you could be interested in pyinotify

  1. https://github.com/seb-m/pyinotify

Other related libraries:

  1. http://people.gnome.org/~veillard/gamin/python.html
  2. Python FAM interface: http://python-fam.sourceforge.net/
  3. http://gorakhargosh.github.com/watchdog/
Rubanov
  • 3,508
  • 1
  • 34
  • 33
pyfunc
  • 63,167
  • 15
  • 145
  • 135
  • [inotify_simple](https://github.com/chrisjbillington/inotify_simple) is pretty good and much simple than pyintoify in my opinion – Hawker65 Jun 29 '18 at 09:46
5

I don't think there's something portable for this kind of requirement. That's too close to the OS IMO. Otherwise for Linux, there's pynotify. pyinotify is a binding for Linux inotify kernel filesystem notification subsystem. Works quite well.

Rubanov
  • 3,508
  • 1
  • 34
  • 33
  • I too had the same understanding that this can't be portable. Luckily my hosting is in Linux and so pynotify is quite suffice. Some developers still use win but i actually don't expect them to use or work on this module. – Gnu Engineer Jan 16 '11 at 23:59
4

I was just looking for a python package that watches file modifications. Just stumbled upon pywatch and it might just be what you're looking for. It's very simple, but does what I need (fixing pyScss' lack of a watcher).

http://pypi.python.org/pypi/pywatch

roberkules
  • 6,469
  • 2
  • 42
  • 51