Created
December 10, 2020 04:31
-
-
Save geyang/c2512286341b3596924664928e8b9f5b to your computer and use it in GitHub Desktop.
Watch script
This file contains 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 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() | |
observer.join() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment