mirror of
https://gitlab.com/jeancf/twoot.git
synced 2024-11-23 20:11:11 +00:00
Correctly test for EOF
This commit is contained in:
parent
f881b46454
commit
652e984f67
7
twoot.py
7
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user