lst_auto_rta.files_callback.dir_monitoring

lst_auto_rta.files_callback.dir_monitoring(log_level: str, log_filename: str, log_format_title: str, info_queue: Queue, stop_event: Event, process_file_fct: Callable, on_dir_change_fct: Callable, file_patterns: List[str] = None, file_ignore_patterns: List[str] = None, monitoring_ignore_directories=True, pattern_case_sensitive: bool = True, query_interval_s: float = 1.0, monitoring_info_received_event: Event | None = None)[source]
Monitors the last directory pushed on info_queue and applies process_file_fct on created files that match

the patterns, until stop event is set. Also executes on_dir_change_fct when the monitoring directoy is changed.

Notes

Files already present in the monitored directory when monitoring starts will be processed as well.

Parameters:
  • log_level (str) – Log level to use for the logger of this function

  • log_filename (str) – Path to the log files to write logs to.

  • log_format_title (str) – “Title” to use in the log files lines.

  • info_queue (MPQueue[DirMonitoringInfo]) – Multiprocessing queue to use to retrieve the directory to monitor and relevant informations to do it.

  • stop_event (SyncEvent) – When this event is set, the monitoring will stop and the function will return.

  • is_monitoring_event (SyncEvent | None)

  • process_file_fct (Callable) – Function to apply to the created files (and already present files) in the monitored directory, passing the file path as argument and extra kwargs based on information in info_queue

  • on_dir_change_fct (Callable) – Function to execute when the directory to monitor is changed (a new one is available in info_queue) The monitored directory path (before change) is passed to the function as argument, with additional kwargs based on information in info_queue.

  • file_patterns (List[str], optional) – List of patterns to filter the created files. See watchdogs PatternMatchingEventHandler documentation. By default None

  • file_ignore_patterns (List[str], optional) – List of patterns to ignore the created files. See watchdogs PatternMatchingEventHandler documentation. By default None

  • monitoring_ignore_directories (bool, optional) – Whether the monitoring should ignore the created subdirectories, by default True

  • pattern_case_sensitive (bool, optional) – If True, the patterns applied to filter or ignore files will be case insensitive, by default True

  • query_interval_s (float, optional) – Amount of time in seconds to wait between 2 processing rounds of created files, by default 1.0

  • is_monitoring_event – A event that is this function will set when starting to query the info_queue. It is mainly used in unit tests to make sure the process monitoring is doing something before stopping the test. Optional, Defaults is None.