fixed log reading at first boot

This commit is contained in:
Simone Margaritelli 2019-09-27 16:38:20 +02:00
parent 0cf80ee8d5
commit 44a912d616

View File

@ -2,6 +2,7 @@ import os
import hashlib import hashlib
import time import time
import re import re
import os
from datetime import datetime from datetime import datetime
from pwnagotchi.mesh.peer import Peer from pwnagotchi.mesh.peer import Peer
@ -129,7 +130,7 @@ class SessionParser(object):
self.duration_human.append('%d seconds' % secs) self.duration_human.append('%d seconds' % secs)
self.duration_human = ', '.join(self.duration_human) self.duration_human = ', '.join(self.duration_human)
self.avg_reward /= self.epochs self.avg_reward /= (self.epochs if self.epochs else 1)
def __init__(self, path='/var/log/pwnagotchi.log'): def __init__(self, path='/var/log/pwnagotchi.log'):
self.path = path self.path = path
@ -147,6 +148,8 @@ class SessionParser(object):
'detected unit (.+)@(.+) \(v.+\) on channel \d+ \(([\d\-]+) dBm\) \[sid:(.+) pwnd_tot:(\d+) uptime:(\d+)\]') 'detected unit (.+)@(.+) \(v.+\) on channel \d+ \(([\d\-]+) dBm\) \[sid:(.+) pwnd_tot:(\d+) uptime:(\d+)\]')
lines = [] lines = []
if os.path.exists(self.path):
with FileReadBackwards(self.path, encoding="utf-8") as fp: with FileReadBackwards(self.path, encoding="utf-8") as fp:
for line in fp: for line in fp:
line = line.strip() line = line.strip()