-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
33 lines (23 loc) · 927 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
import os
from src.regexgen import generate_regex_for_ts, get_matches_from_file
from src.config import ProdConfig
from src.models import ValidatorLog
def crawl_log_files() -> None:
directory = ProdConfig.PATH_VALIDATOR_LOG_FILES
print(f"Crawling directory: {directory}")
for r in ProdConfig.TIME_GAP_LIST:
regex = generate_regex_for_ts(r[0], r[1])
print(f"REGEX for range {r[0]} > {r[1]}:")
print(f"{regex}")
print(f"-"*50)
for filename in os.listdir(directory):
f = os.path.join(directory, filename)
print(f"Crawling file {filename}")
if os.path.isfile(f):
matches = get_matches_from_file(regex, f)
ValidatorLog.load_list_matches(filename, matches)
print(f"{len(matches)} matches found!")
print("Done!")
if __name__ == "__main__":
crawl_log_files()