From 568c5b020dac804f10b8297cfdb07ca0d096913a Mon Sep 17 00:00:00 2001 From: dadav <33197631+dadav@users.noreply.github.com> Date: Wed, 15 Apr 2020 17:19:41 +0200 Subject: [PATCH] aaaannnd even better --- pwnagotchi/plugins/default/logtail.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pwnagotchi/plugins/default/logtail.py b/pwnagotchi/plugins/default/logtail.py index c3c8fed..086bf73 100644 --- a/pwnagotchi/plugins/default/logtail.py +++ b/pwnagotchi/plugins/default/logtail.py @@ -1,6 +1,7 @@ import os import logging import threading +from itertools import islice from time import sleep from datetime import datetime,timedelta from pwnagotchi import plugins @@ -273,6 +274,10 @@ class Logtail(plugins.Plugin): if path == 'stream': def generate(): with open(self.config['main']['log']['path']) as f: + # https://stackoverflow.com/questions/39549426/read-multiple-lines-from-a-file-batch-by-batch/39549901#39549901 + n = 1024 + for n_lines in iter(lambda: ''.join(islice(f, n)), ''): + yield n_lines while True: yield f.readline()