add experiment scripts and results; watcher.py latest changes
This commit is contained in:
+43
-8
@@ -299,22 +299,57 @@ class IngestHandler(FileSystemEventHandler):
|
||||
self.pending = False
|
||||
self.last_event = 0
|
||||
|
||||
def on_any_event(self, event):
|
||||
def _should_ignore(self, path: Path) -> bool:
|
||||
if path.name.startswith((".", "~$")):
|
||||
return True
|
||||
if "Admin/Backups" in str(path) or "Backups" in path.parts:
|
||||
return True
|
||||
if "Journal/Media" in str(path):
|
||||
return True
|
||||
return False
|
||||
|
||||
def on_created(self, event):
|
||||
if event.is_directory:
|
||||
return
|
||||
path = Path(event.src_path)
|
||||
if path.suffix.lower() not in SUPPORTED:
|
||||
if path.suffix.lower() not in SUPPORTED or self._should_ignore(path):
|
||||
return
|
||||
if path.name.startswith((".", "~$")):
|
||||
log.info(f"Event: created {path}")
|
||||
self.pending = True
|
||||
self.last_event = time.time()
|
||||
|
||||
def on_modified(self, event):
|
||||
if event.is_directory:
|
||||
return
|
||||
if "Admin/Backups" in str(path) or "Backups" in path.parts:
|
||||
path = Path(event.src_path)
|
||||
if path.suffix.lower() not in SUPPORTED or self._should_ignore(path):
|
||||
return
|
||||
if "Journal/Media" in str(path):
|
||||
log.info(f"Event: modified {path}")
|
||||
self.pending = True
|
||||
self.last_event = time.time()
|
||||
|
||||
def on_moved(self, event):
|
||||
if event.is_directory:
|
||||
return
|
||||
if event.event_type not in ("modified", "created", "moved"):
|
||||
# Nextcloud WebDAV writes .part temp files then renames to final path.
|
||||
# src_path is the .part file; dest_path is the final filename.
|
||||
dest = Path(event.dest_path)
|
||||
if dest.suffix.lower() not in SUPPORTED or self._should_ignore(dest):
|
||||
return
|
||||
log.info(f"Event: {event.event_type} {event.src_path}")
|
||||
self.pending = True
|
||||
log.info(f"Event: moved -> {dest}")
|
||||
self.pending = True
|
||||
self.last_event = time.time()
|
||||
|
||||
def on_closed(self, event):
|
||||
# FileClosedEvent fires on the final file after Nextcloud completes write.
|
||||
# Belt-and-suspenders catch for any write pattern not caught by on_moved.
|
||||
if event.is_directory:
|
||||
return
|
||||
path = Path(event.src_path)
|
||||
if path.suffix.lower() not in SUPPORTED or self._should_ignore(path):
|
||||
return
|
||||
log.info(f"Event: closed {path}")
|
||||
self.pending = True
|
||||
self.last_event = time.time()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user