fix: handling corrupted log lines (fixes #321)

This commit is contained in:
Simone Margaritelli
2019-10-18 10:30:27 +02:00
parent eeee4bdd3c
commit 8c73e32853

View File

@ -2,6 +2,7 @@ import hashlib
import time import time
import re import re
import os import os
import logging
from datetime import datetime from datetime import datetime
from pwnagotchi.voice import Voice from pwnagotchi.voice import Voice
@ -87,6 +88,8 @@ class LastSession(object):
parts = line.split(']') parts = line.split(']')
if len(parts) < 2: if len(parts) < 2:
continue continue
try:
line_timestamp = parts[0].strip('[') line_timestamp = parts[0].strip('[')
line = ']'.join(parts[1:]) line = ']'.join(parts[1:])
stopped_at = self._parse_datetime(line_timestamp) stopped_at = self._parse_datetime(line_timestamp)
@ -142,6 +145,8 @@ class LastSession(object):
cache[pubkey] = self.last_peer cache[pubkey] = self.last_peer
else: else:
cache[pubkey].adv['pwnd_tot'] = pwnd_tot cache[pubkey].adv['pwnd_tot'] = pwnd_tot
except Exception as e:
logging.error("error parsing line '%s': %s" % (line, e))
if started_at is not None: if started_at is not None:
self.duration = stopped_at - started_at self.duration = stopped_at - started_at