summaryrefslogtreecommitdiff
path: root/client/helper.py
diff options
context:
space:
mode:
Diffstat (limited to 'client/helper.py')
-rw-r--r--client/helper.py63
1 files changed, 63 insertions, 0 deletions
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()