-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathwatch.py
More file actions
33 lines (27 loc) · 916 Bytes
/
watch.py
File metadata and controls
33 lines (27 loc) · 916 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import sys
import time
import logging
import os
import subprocess
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
class SourceWatchHandler(LoggingEventHandler):
def on_modified(self, event):
super(LoggingEventHandler, self).on_modified(event)
subprocess.call(['make', 'generate_dev'])
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
BASE_PATH = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(BASE_PATH, 'source')
event_handler = SourceWatchHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()