2011-08-05 3 views

Répondre

5

Si vous voulez envelopper ceci dans un script Python, vous pouvez utiliser Chien de garde qui fonctionne aussi bien avec Linux et OSX.

https://pypi.python.org/pypi/watchdog

Voici ce qu'il ressemble à remplacer pyinotify avec chien de garde:

https://github.com/raphdg/baboon/commit/2c115da63dac16d0fbdc9b45067d0ab0960143ed

chien de garde a également un utilitaire shell appelé watchmedo:

watchmedo shell-command \ 
    --patterns="*.py;*.txt" \ 
    --recursive \ 
    --command='echo "${watch_src_path}"' \ 
    . 
3

Oui, vous pouvez utiliser le FSEvents API

+0

peut-il être utilisé dans un script shell? –

+1

Non, mais il existe une librairie wrapper pour python: http://pypi.python.org/pypi/MacFSEvents/0.2.4 – Baversjo

0

Vous pouvez utiliser entr outil. Exemple d'utilisation:

ls some_file | entr do_something 

Sur Mac installer via Brew: brew install entr.