-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollector.py
More file actions
30 lines (24 loc) · 952 Bytes
/
Copy pathcollector.py
File metadata and controls
30 lines (24 loc) · 952 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
import time
import os
from collections import deque
from watchdog.events import FileSystemEventHandler
event_buffer = deque()
IGNORE_FILES = {"detection_output.json"}
class MonitorHandler(FileSystemEventHandler):
def on_modified(self, event):
if not event.is_directory:
if os.path.basename(event.src_path) in IGNORE_FILES:
return
event_buffer.append((time.time(), "modified", event.src_path))
def on_created(self, event):
if not event.is_directory:
if os.path.basename(event.src_path) in IGNORE_FILES:
return
event_buffer.append((time.time(), "created", event.src_path))
def on_deleted(self, event):
if not event.is_directory:
if os.path.basename(event.src_path) in IGNORE_FILES:
return
event_buffer.append((time.time(), "deleted", event.src_path))
def get_buffer():
return event_buffer