Do not scan the log file if it is older than a day old

This commit is contained in:
Hugo 2021-09-18 15:57:44 +02:00
parent 4a1c96574b
commit bb713a9a21
1 changed files with 3 additions and 1 deletions

View File

@ -164,7 +164,9 @@ def parse_logfile(logfile_path: str, locations: List[str],
visit_dict: VisitDict = dict(map(lambda x: (x, set()), locations))
bot_visit_dict: VisitDict = dict(map(lambda x: (x, set()), locations))
other_visit_dict: VisitDict = defaultdict(set)
if abs(os.path.getmtime(logfile_path) - datetime.now().timestamp()) >= 24 * 3600:
print("Log file is too old, there was no access today.")
logfile_path="/dev/null"
with open(logfile_path, 'r', encoding='utf-8') as logfile:
for line in logfile:
match_obj = re.match(known_page_regex, line)