fix: handling corrupted log lines (fixes )

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

@ -2,6 +2,7 @@ import hashlib
import time
import re
import os
import logging
from datetime import datetime
from pwnagotchi.voice import Voice
@ -87,6 +88,8 @@ class LastSession(object):
parts = line.split(']')
if len(parts) < 2:
continue
try:
line_timestamp = parts[0].strip('[')
line = ']'.join(parts[1:])
stopped_at = self._parse_datetime(line_timestamp)
@ -142,6 +145,8 @@ class LastSession(object):
cache[pubkey] = self.last_peer
else:
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:
self.duration = stopped_at - started_at