-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_watcher.py
More file actions
59 lines (48 loc) · 1.98 KB
/
start_watcher.py
File metadata and controls
59 lines (48 loc) · 1.98 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# start_watcher.py
import time
import os
import subprocess
from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
# --- Configuration ---
# The folder we will be watching for new transcript files.
# IMPORTANT: Make sure this folder exists!
WATCH_FOLDER = os.path.expanduser("~/Downloads/LimitlessTranscripts")
class TranscriptHandler(FileSystemEventHandler):
"""
This class defines what happens when a file event occurs.
"""
def on_created(self, event):
# This method is called when a new file is created.
if not event.is_directory and event.src_path.endswith('.txt'):
print(f"📄 New transcript detected: {os.path.basename(event.src_path)}")
print("🚀 Launching analysis script...")
# Use subprocess to call our existing process_meeting.py script.
# We pass the path of the new file to the script.
# Note: We use 'python' which should resolve to the one in our venv.
subprocess.run(["python", "process_meeting.py", event.src_path])
print("\n✅ Analysis complete. Watching for next file...")
def start_watcher():
"""
Sets up and starts the directory watcher.
"""
print("--- Aura Watcher Service ---")
# Create the watch folder if it doesn't exist
if not os.path.exists(WATCH_FOLDER):
print(f"⚠️ Watch folder not found. Creating folder at: {WATCH_FOLDER}")
os.makedirs(WATCH_FOLDER)
print(f"👀 Watching for new .txt files in: {WATCH_FOLDER}")
event_handler = TranscriptHandler()
observer = Observer()
observer.schedule(event_handler, WATCH_FOLDER, recursive=False)
observer.start()
print("✅ Watcher started successfully. Press Ctrl+C to stop.")
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
print("\n🛑 Watcher stopped.")
observer.join()
if __name__ == "__main__":
start_watcher()