From 652e984f67ccb9b0c2422ff235f8aaa837187411 Mon Sep 17 00:00:00 2001 From: jeancf Date: Sun, 11 Dec 2022 22:42:19 +0100 Subject: [PATCH] Correctly test for EOF --- twoot.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/twoot.py b/twoot.py index 8480dd4..f23ae9d 100755 --- a/twoot.py +++ b/twoot.py @@ -563,14 +563,19 @@ def terminate(exit_code): # Check each line pos = log_file.tell() - while log_file: + while True: line = log_file.readline() + # Check if we reached the end of the file + if not line: + exit(exit_code) + try: # Extract date on log line date = datetime.strptime(line[:10], '%Y-%m-%d') except ValueError: # date was not found on this line, try next one continue + # Time difference between log message and now log_delta = datetime.now() - date # Only keep the number of days of the difference