Skip to content

Instantly share code, notes, and snippets.

@sveetch
Created April 21, 2015 17:09
Show Gist options
  • Save sveetch/8e4e18a203fb3de06759 to your computer and use it in GitHub Desktop.
Save sveetch/8e4e18a203fb3de06759 to your computer and use it in GitHub Desktop.
Script to test watchdog
"""
Testing watchdog (mostly for OSX)
* Create a directory into your virtual environment, like "taiste";
* Go into this directory;
* Put this script into this directory;
* Run it with: python watchit.py
* Add files, edit files, remove files;
* See the logs if events are showed for changes you do previously on your files;
* Exit from the script when you are done using CTRL+C (or CMD+C on OSX);
"""
import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
path = sys.argv[1] if len(sys.argv) > 1 else '.'
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
@fredDesign
Copy link

it works for me , watchdog make the job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment