From 58ebd3bc0f00c532e97e9a5571471ffab87934ba Mon Sep 17 00:00:00 2001 From: AL-LCL Date: Fri, 19 May 2023 10:39:49 +0200 Subject: GOD-VIEW --- client/helper.py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 client/helper.py (limited to 'client/helper.py') diff --git a/client/helper.py b/client/helper.py new file mode 100644 index 0000000..2c90a52 --- /dev/null +++ b/client/helper.py @@ -0,0 +1,63 @@ +''' + General helper functions to improve order + & flow of the client program. + + Verified: 2020 December 30 & 2021 February 6 + * Follows PEP8 + * Tested Platforms + * Windows 10 +''' + +from client.state import ClientStatic +from shared.helper import Helper +from shared.state import Static + +import sys + +if Static.EXE: + if Static.WINDOWS: + from client.autostart import (AutoShell, + AutoRegistry, + AutoSchedule) + + from shared.error import Error + + import os + + +class ClientHelper: + + @staticmethod + def secure(callback): + try: + result = callback() + assert type(result) is str + return result + except Exception: + return ClientStatic.DEFAULT + + @staticmethod + def plural_int(number): + if number == 1: + return '' + else: + return 's' + + @staticmethod + def restart(): + try: + sys.exit() + finally: + Helper.start(Static.ROOT) + + @staticmethod + def uninstall(): + if Static.EXE: + if Static.WINDOWS: + AutoShell.uninstall() + Error.quiet(AutoRegistry.uninstall)() + Error.quiet(AutoSchedule.uninstall)() + + Error.quiet(os.remove)(Static.ROOT) + + sys.exit() -- cgit v1.2.3