From 2c51e62a7ddeef23c7eca806d76191ce754b09f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20M=C3=BCller=20=28ChaoticByte=29?= Date: Mon, 17 Apr 2023 20:52:08 +0200 Subject: [PATCH] Added a text banner that is displayed in the terminal/logfile on application startup, fixed a wrongly indented code block --- scripts/_bootstrap.py | 53 +++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/scripts/_bootstrap.py b/scripts/_bootstrap.py index 9533953..71ce28d 100755 --- a/scripts/_bootstrap.py +++ b/scripts/_bootstrap.py @@ -14,6 +14,17 @@ from time import sleep from yaml import safe_load +banner = """ ___ _ _ +| \ _ _ (_) _ _ | |__ ___ ___ +| |) || '_|| || ' \ | / /(_-< |___| +|___/ |_| |_||_||_||_\_\/__/ + __ __ Version {version} +| \/ | __ _ _ _ __ _ __ _ ___ _ _ +| |\/| |/ _` || ' \ / _` |/ _` |/ -_)| '_| +|_| |_|\__,_||_||_|\__,_|\__, |\___||_| + |___/ +""" + base_directory = Path(__file__).parent.parent data_directory = base_directory / "data" logfile_directory = data_directory / "logs" @@ -79,27 +90,29 @@ def cleanup_procs(processes): def start_and_monitor(monitored_subprocesses: list): + # display banner + print(banner.format(version=os.environ["APP_VERSION"])) # start processes - for p in monitored_subprocesses: - p.try_start() - register_exithandler(cleanup_procs, monitored_subprocesses) - # monitor processes - try: - while True: - sleep(1) - for p in monitored_subprocesses: - returncode = p.s.poll() - if returncode is None: - continue - else: - print(f"{p.name} stopped with exit code {returncode}.") - if p.try_start() is False: - # stop everything if the process - # has exceeded max. tries - exit() - except KeyboardInterrupt: - print("Received KeyboardInterrupt, exiting...") - exit() + for p in monitored_subprocesses: + p.try_start() + register_exithandler(cleanup_procs, monitored_subprocesses) + # monitor processes + try: + while True: + sleep(1) + for p in monitored_subprocesses: + returncode = p.s.poll() + if returncode is None: + continue + else: + print(f"{p.name} stopped with exit code {returncode}.") + if p.try_start() is False: + # stop everything if the process + # has exceeded max. tries + exit() + except KeyboardInterrupt: + print("Received KeyboardInterrupt, exiting...") + exit() if __name__ == "__main__":