mirror of
https://github.com/FAUSheppy/skillbird
synced 2025-12-09 16:08:31 +01:00
time now using correct timestamp
This commit is contained in:
@@ -3,8 +3,6 @@ import time
|
|||||||
import threading
|
import threading
|
||||||
import insurgencyParsing as iparse
|
import insurgencyParsing as iparse
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
DATE_LENGTH = 15
|
DATE_LENGTH = 15
|
||||||
|
|
||||||
def readfile(filename, start_at_end, exit_on_eof, parsingBackend, startAtTime, cacheFile, cpus=1):
|
def readfile(filename, start_at_end, exit_on_eof, parsingBackend, startAtTime, cacheFile, cpus=1):
|
||||||
@@ -17,7 +15,7 @@ def readfile(filename, start_at_end, exit_on_eof, parsingBackend, startAtTime, c
|
|||||||
while True:
|
while True:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
try:
|
try:
|
||||||
dt = datetime.strptime(line[:DATE_LENGTH], "%b %d %H:%M:%S")
|
dt = parsingBackend.parseDate(line)
|
||||||
if not dt:
|
if not dt:
|
||||||
break
|
break
|
||||||
if dt > startAtTime:
|
if dt > startAtTime:
|
||||||
|
|||||||
@@ -190,15 +190,20 @@ def create_event(etype,line,timestamp):
|
|||||||
else:
|
else:
|
||||||
raise Exception("Cannot create event from logline. (etype was: '{}')".format(etype))
|
raise Exception("Cannot create event from logline. (etype was: '{}')".format(etype))
|
||||||
|
|
||||||
def parse_line_to_event(l):
|
def parseDate(line):
|
||||||
tmp = l.split("0x42,")[1].strip("\n")
|
|
||||||
etype = tmp.split(",")[0].split("|")[0]
|
|
||||||
try:
|
|
||||||
if ": L " in l.split("0x42")[0]:
|
if ": L " in l.split("0x42")[0]:
|
||||||
timestamp = datetime.strptime(l.split(": L ")[1].split(": [")[0],"%m/%d/%Y - %H:%M:%S")
|
timestamp = datetime.strptime(l.split(": L ")[1].split(": [")[0],"%m/%d/%Y - %H:%M:%S")
|
||||||
else:
|
else:
|
||||||
timestamp = datetime.strptime(l.split(": [ints_logging.smx]")[0],"L %m/%d/%Y - %H:%M:%S")
|
timestamp = datetime.strptime(l.split(": [ints_logging.smx]")[0],"L %m/%d/%Y - %H:%M:%S")
|
||||||
|
return timestamp
|
||||||
|
|
||||||
|
|
||||||
|
def parse_line_to_event(l):
|
||||||
|
tmp = l.split("0x42,")[1].strip("\n")
|
||||||
|
etype = tmp.split(",")[0].split("|")[0]
|
||||||
|
try:
|
||||||
event = create_event(etype,tmp,timestamp)
|
event = create_event(etype,tmp,timestamp)
|
||||||
|
timestamp = parseDate(line)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
print(" ---- NO TIME ---- | WARNING: Failed to parse time for event, SKIP")
|
print(" ---- NO TIME ---- | WARNING: Failed to parse time for event, SKIP")
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user