How to watch a directory for changes? [duplicate]

妖精的绣舞 提交于 2019-12-17 16:33:46

问题


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


回答1:


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/



回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/4708511/how-to-watch-a-directory-for-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!