qass.tools.analyzer.deleting_process
Classes:
| Name | Description |
|---|---|
DeleteHandler |
DeleteHandler Class with different functionalities to delete local files on disk. |
DeleteHandler
DeleteHandler Class with different functionalities to delete local files on disk.
With an instance of this class a specific deleting-pattern and path (for the files) will be associated. The programm always looks for the oldest versions of files which match with the pattern. Files will be deletet until the maximum amount of allowed files is reached or enough disk space is free. This class stands for now on its own. With a def main() syntacs it will be executed by programm start.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Local directory path. |
required |
pattern
|
str
|
Searched pattern. |
required |
pattern
|
bool
|
Flag if log file should be created (by default: False) |
required |
Methods:
| Name | Description |
|---|---|
__init__ |
Constructor to connect a specific local directory path with a specific pattern parsed. |
delete_by_amount |
Provided function to delete files based on file amount in location if amount overruns defined limit. |
delete_by_disk_space |
Provided method to delete files by a given maximum disk space usage. |
Attributes:
| Name | Type | Description |
|---|---|---|
file_logger |
|
|
full_path |
|
|
log_entries |
|
|
path |
|
|
pattern |
|
Source code in src/qass/tools/analyzer/deleting_process.py
33 34 35 36 37 38 39 40 41 42 43 44 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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | |
file_logger
instance-attribute
__delete_file
Private method to delete parsed file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deleting_file
|
str
|
File(path) that should be deletet. |
required |
Raises:
| Type | Description |
|---|---|
OSError
|
An error is raisen if files cannot be removed (arbitrary reasons). |
Source code in src/qass/tools/analyzer/deleting_process.py
__get_oldest
Private method to get a list of local files which are sorted by creation date.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
possible_files
|
list
|
Everything in directory which matches pattern. |
required |
Returns:
| Type | Description |
|---|---|
list
|
Sorted list with the oldest files as first entry. |
Source code in src/qass/tools/analyzer/deleting_process.py
__init__
Constructor to connect a specific local directory path with a specific pattern parsed.
Provided functions can be applied later for each combination. Pattern has to be according to the rules used by Unix shell (used glob module is based on that). In the following Unix Shell rules are provided:
| Pattern | Meaning | Example |
|---|---|---|
| * | Matches everything | *.pdf matches all files with the pdf extension |
| ? | Matches any single character | sales/??.jpeg matches all files with two characters long present in the sales folder |
| [] | Matches any character in the sequence | [psr]* matches all files starting with the letter p, s, or r |
| [!] | Matches any character not in sequence | [!psr]* matches all files not starting with the letter p, s, or r |
For a literal match, wrap the meta-characters in brackets. For example, '[?]' matches the character '?'
Note
Created logfile be ignored automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Local directory path. |
required |
pattern
|
str
|
Searched pattern. |
required |
Source code in src/qass/tools/analyzer/deleting_process.py
delete_by_amount
Provided function to delete files based on file amount in location if amount overruns defined limit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_amount
|
int
|
Maximum amount (limit) of files allowed in this directory which are match pattern. |
required |
Source code in src/qass/tools/analyzer/deleting_process.py
delete_by_disk_space
Provided method to delete files by a given maximum disk space usage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disk_usage_limit
|
float
|
Limit how much disk memory is allowed to use at maximum. Parsed as part of the whole. |
required |
Raises:
| Type | Description |
|---|---|
OSError
|
Exception is raised if deleting process cannot be compelted. Either because there are not enough files that match pattern to satisfy limit or because any other wild error appears. |