fix log analyzer

This commit is contained in:
Torma Kristóf 2019-11-03 23:23:00 +01:00
parent 4b7f1752ec
commit 73eb21e850
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
1 changed files with 5 additions and 4 deletions

View File

@ -22,26 +22,27 @@ def readfile() -> list:
with open("log.txt", 'r') as inputFile:
line = inputFile.readline()
while line:
line = inputFile.readline()
try:
linedict = json.loads(line)
lines.append(linedict)
except json.JSONDecodeError:
continue
finally:
line = inputFile.readline()
return lines
def readconfigdates() -> dict:
dates = {}
with open("dates.txt", 'r') as inputFile:
line = inputFile.readline()
line = inputFile.readline().rstrip()
currline = 0
while line:
line = inputFile.readline()
currline += 1
dateformatted = datetime.datetime.strptime(
line, '%Y-%m-%d %H:%M:%S')
dates[currline] = dateformatted
line = inputFile.readline().rstrip()
currline += 1
return dates