mirror of
https://gitlab.com/jeancf/twoot.git
synced 2025-04-15 17:27:34 +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
|
# Check each line
|
||||||
pos = log_file.tell()
|
pos = log_file.tell()
|
||||||
while log_file:
|
while True:
|
||||||
line = log_file.readline()
|
line = log_file.readline()
|
||||||
|
# Check if we reached the end of the file
|
||||||
|
if not line:
|
||||||
|
exit(exit_code)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Extract date on log line
|
# Extract date on log line
|
||||||
date = datetime.strptime(line[:10], '%Y-%m-%d')
|
date = datetime.strptime(line[:10], '%Y-%m-%d')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
# date was not found on this line, try next one
|
# date was not found on this line, try next one
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Time difference between log message and now
|
# Time difference between log message and now
|
||||||
log_delta = datetime.now() - date
|
log_delta = datetime.now() - date
|
||||||
# Only keep the number of days of the difference
|
# Only keep the number of days of the difference
|
||||||
|
Loading…
x
Reference in New Issue
Block a user