From 4ca441bba39b6973dc02543bfc80b324b795a9bf Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Thu, 2 May 2024 07:08:23 +0200 Subject: [PATCH] test for log since last boot --- cbpi/__init__.py | 2 +- cbpi/controller/system_controller.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index ddc10e3..9c63548 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.4.1.a4" +__version__ = "4.4.1.a5" __codename__ = "Yeast Starter" diff --git a/cbpi/controller/system_controller.py b/cbpi/controller/system_controller.py index c5b4256..104ea71 100644 --- a/cbpi/controller/system_controller.py +++ b/cbpi/controller/system_controller.py @@ -146,7 +146,22 @@ class SystemController: output_filename="cbpi4_log.zip" if logtime == "b": - os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname)) + if systemd_available: + #os.system('journalctl -b -u craftbeerpi.service --output cat > {}'.format(fullname)) + j = journal.Reader() + j.add_match(_TRANSPORT="kernel") + result=[] + for entry in j: + message=entry['MESSAGE'] + if message.find("Booting") != -1: + result.append(entry['__REALTIME_TIMESTAMP']) + j.add_match(_SYSTEMD_UNIT="craftbeerpi.service") + j.seek_realtime(result[-1]) + for entry in j: + timestamp=entry['__REALTIME_TIMESTAMP'] + message=entry['MESSAGE'] + print(message) + else: if systemd_available: result=[]