lstautorta.files_callback
Classes:
| Name | Description |
|---|---|
DirMonitoringInfo |
Information required by |
QueueingFilePatternMatchingEventHandler |
Handler that queues (blocking) the file paths of created files that matched the patterns |
Functions:
| Name | Description |
|---|---|
dir_monitoring |
Monitor the last directory pushed on |
DirMonitoringInfo
Bases: NamedTuple
flowchart TD
lstautorta.files_callback.DirMonitoringInfo[DirMonitoringInfo]
click lstautorta.files_callback.DirMonitoringInfo href "" "lstautorta.files_callback.DirMonitoringInfo"
Information required by dir_monitoring to start monitoring a directory. Typically received from a multiprocessing Queue.
Source code in src/lstautorta/files_callback.py
QueueingFilePatternMatchingEventHandler
Bases: PatternMatchingEventHandler
flowchart TD
lstautorta.files_callback.QueueingFilePatternMatchingEventHandler[QueueingFilePatternMatchingEventHandler]
click lstautorta.files_callback.QueueingFilePatternMatchingEventHandler href "" "lstautorta.files_callback.QueueingFilePatternMatchingEventHandler"
Handler that queues (blocking) the file paths of created files that matched the patterns
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_queue
|
Queue
|
The queue to use to queue the files created. |
required |
Source code in src/lstautorta/files_callback.py
dir_monitoring
dir_monitoring(log_level, log_filename, log_format_title, info_queue, stop_event, process_file_fct, on_dir_change_fct, file_patterns=None, file_ignore_patterns=None, monitoring_ignore_directories=True, pattern_case_sensitive=True, query_interval_s=1.0, monitoring_info_received_event=None)
Monitor 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:
| Name | Type | Description | Default |
|---|---|---|---|
log_level
|
str
|
Log level to use for the logger of this function |
required |
log_filename
|
str
|
Path to the log files to write logs to. |
required |
log_format_title
|
str
|
"Title" to use in the log files lines. |
required |
info_queue
|
Queue[DirMonitoringInfo]
|
Multiprocessing queue to use to retrieve the directory to monitor and relevant informations to do it. |
required |
stop_event
|
Event
|
When this event is set, the monitoring will stop and the function will return. |
required |
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 |
required |
on_dir_change_fct
|
Callable
|
Function to execute when the directory to monitor is changed (a new one is available in |
required |
file_patterns
|
List[str]
|
List of patterns to filter the created files. See watchdogs PatternMatchingEventHandler documentation. By default None |
None
|
file_ignore_patterns
|
List[str]
|
List of patterns to ignore the created files. See watchdogs PatternMatchingEventHandler documentation. By default None |
None
|
monitoring_ignore_directories
|
bool
|
Whether the monitoring should ignore the created subdirectories, by default True |
True
|
pattern_case_sensitive
|
bool
|
If True, the patterns applied to filter or ignore files will be case insensitive, by default True |
True
|
query_interval_s
|
float
|
Amount of time in seconds to wait between 2 processing rounds of created files, by default 1.0 |
1.0
|
Source code in src/lstautorta/files_callback.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | |