-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetect_cpp.py
More file actions
24 lines (21 loc) · 740 Bytes
/
detect_cpp.py
File metadata and controls
24 lines (21 loc) · 740 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
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import os
class NewFileHandler(FileSystemEventHandler):
def on_created(self, event):
if event.is_directory or not event.src_path.endswith(".cpp"):
return
new_file = os.path.basename(event.src_path)
os.system(f"python3 automate.py {new_file}")
if __name__ == "__main__":
path_to_watch = "Path to your cpp working repository"
event_handler = NewFileHandler()
observer = Observer()
observer.schedule(event_handler, path=path_to_watch, recursive=False)
observer.start()
try:
while True:
pass
except KeyboardInterrupt:
observer.stop()
observer.join()