예제 #1
0
    def _check_for_work(self):
        self._run_scheduled()
        self._cleanup_running()

        events = []
        while not self._q.empty():
            events.append(self._q.get())

        for item_type in self._work_items:
            for ev in events:
                if not item_type.path_matcher(ev.src_path):
                    continue
                if self.is_scheduled(item_type, ev.src_path):
                    continue
                new_item = item_type()
                new_item._paths.add(ev.src_path)
                self._scheduled.append(new_item)
예제 #2
0
def generate_dolphin_csv(filename: str, directory: str) -> int:
    """
    Write the events from the scb files in the given directory into a CSV
    for Dolphin.
    """
    files = os.scandir(directory)
    events = []
    for file in files:
        if file.name.endswith(".scb"):
            event = results.Event()
            event.from_scb(file.path)
            events.append(event)
    events.sort(key=lambda e: e.event_num)
    csv_lines = eventlist_to_csv(events)
    outfile = os.path.join(directory, filename)
    with open(outfile, "w", encoding="cp1252") as csv:
        csv.writelines(csv_lines)
    return len(events)
예제 #3
0
 def handle(ev: watchdog.events.FileSystemEvent) -> None:
     if ev.is_directory:
         return
     events.append((ev.event_type, ev.src_path))