From f3b03827e2edd1f791402fd75de05fedcf70c8bb Mon Sep 17 00:00:00 2001 From: Migatu Date: Sat, 18 May 2024 12:45:18 +0200 Subject: [PATCH] Adding script logging current tracks in queue --- conjurer_musician/music_utils.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 conjurer_musician/music_utils.py diff --git a/conjurer_musician/music_utils.py b/conjurer_musician/music_utils.py new file mode 100644 index 0000000..7ea171e --- /dev/null +++ b/conjurer_musician/music_utils.py @@ -0,0 +1,26 @@ +# This Python file uses the following encoding: utf-8 +"""This module contains utility scripts used by musi radiostation Conjurer""" +import time +import re + +NAME = "/home/pi/Conjurer/persistence.log" + +def print_top(): + """ + Prints the top 65 lines from a file specified by the NAME variable. + """ + while True: + line = "" + buffer = "" + with open(NAME, "r", encoding="utf-8") as f: + for _ in range (65): + line = f.readline() + if re.match("", line): + buffer += line + print("=====================================") + print(buffer) + print("=====================================") + time.sleep(180) + +if __name__ == "__main__": + print_top()