diff --git a/bin/pwnagotchi b/bin/pwnagotchi index 9405fe8..82e4712 100755 --- a/bin/pwnagotchi +++ b/bin/pwnagotchi @@ -57,7 +57,7 @@ if __name__ == '__main__': elif args.do_manual: logging.info("entering manual mode ...") - agent.last_session.parse(args.skip_session) + agent.last_session.parse(agent.view(), args.skip_session) if not args.skip_session: logging.info( "the last session lasted %s (%d completed epochs, trained for %d), average reward:%s (min:%s max:%s)" % ( diff --git a/pwnagotchi/log.py b/pwnagotchi/log.py index 7177cc0..8ba77d5 100644 --- a/pwnagotchi/log.py +++ b/pwnagotchi/log.py @@ -167,12 +167,14 @@ class LastSession(object): self.duration_human = ', '.join(self.duration_human) self.avg_reward /= (self.epochs if self.epochs else 1) - def parse(self, skip=False): + def parse(self, ui, skip=False): if skip: logging.debug("skipping parsing of the last session logs ...") else: logging.debug("reading last session logs ...") + ui.on_reading_logs() + lines = [] if os.path.exists(self.path): @@ -184,11 +186,18 @@ class LastSession(object): lines.append(line) if LastSession.START_TOKEN in line: break + + lines_so_far = len(lines) + if lines_so_far % 100 == 0: + ui.on_reading_logs(lines_so_far) + lines.reverse() if len(lines) == 0: lines.append("Initial Session"); + ui.on_reading_logs() + self.last_session = lines self.last_session_id = hashlib.md5(lines[0].encode()).hexdigest() self.last_saved_session_id = self._get_last_saved_session_id() diff --git a/pwnagotchi/ui/view.py b/pwnagotchi/ui/view.py index 94a34e1..3a4358e 100644 --- a/pwnagotchi/ui/view.py +++ b/pwnagotchi/ui/view.py @@ -233,6 +233,11 @@ class View(object): self.set('status', self._voice.on_free_channel(channel)) self.update() + def on_reading_logs(self, lines_so_far=0): + self.set('face', faces.SMART) + self.set('status', self._voice.on_reading_logs(lines_so_far)) + self.update() + def wait(self, secs, sleeping=True): was_normal = self.is_normal() part = secs / 10.0 diff --git a/pwnagotchi/voice.py b/pwnagotchi/voice.py index c832f19..0d06b6c 100644 --- a/pwnagotchi/voice.py +++ b/pwnagotchi/voice.py @@ -43,6 +43,12 @@ class Voice: def on_free_channel(self, channel): return self._('Hey, channel {channel} is free! Your AP will say thanks.').format(channel=channel) + def on_reading_logs(self, lines_so_far=0): + if lines_so_far == 0: + return self._('Reading last session logs ...') + else: + return self._('Read {lines_so_far} log lines so far ...').format(lines_so_far=lines_so_far) + def on_bored(self): return random.choice([ self._('I\'m bored ...'),