From 8554d27cc7fefe1d094e70853a3ca42c4cdd1c6e Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Sun, 18 Oct 2020 18:15:59 +0200 Subject: [PATCH] client.py: Always restart on errors if on kiosk mode except on graceful exit --- playbook/templates/client.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/playbook/templates/client.py b/playbook/templates/client.py index 2abeed6..a4458dc 100755 --- a/playbook/templates/client.py +++ b/playbook/templates/client.py @@ -51,7 +51,15 @@ def select_ui(win, args): pass if args.kiosk: subprocess.call(['systemctl', 'poweroff']) + return True # exited as expected +def retry(fun): + last_return = False + while not last_return: + try: + last_return = fun() + except: + pass # TODO save log file with error def main(): parser = argparse.ArgumentParser(add_help=False) @@ -66,7 +74,12 @@ def main(): parts = [part.replace('_', ' ') for part in parts] print(str(' - '.join(parts))) return - curses.wrapper(select_ui, args) + def run(): + curses.wrapper(select_ui, args) + if args.kiosk: + retry(run) + else: + run() if __name__ == '__main__': main()