Skip to content

Instantly share code, notes, and snippets.

@koenbok
Created March 18, 2014 10:32
Show Gist options
  • Select an option

  • Save koenbok/9617527 to your computer and use it in GitHub Desktop.

Select an option

Save koenbok/9617527 to your computer and use it in GitHub Desktop.
Simple watch script for macfsevents (great for nose tests)
import os
import sys
import time
from fsevents import Stream, Observer
if __name__ == '__main__':
if (len(sys.argv)) < 2:
sys.exit("No command found")
command = " ".join(sys.argv[1:])
os.system(command)
def callback(event):
if not event.name.endswith(".py"):
return
print event.name
os.system(command)
observer = Observer()
observer.start()
stream = Stream(callback, ".", file_events=True)
observer.schedule(stream)
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment