Created
March 18, 2014 10:32
-
-
Save koenbok/9617527 to your computer and use it in GitHub Desktop.
Simple watch script for macfsevents (great for nose tests)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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