aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-09-10 20:57:46 +0300
committerChristos.K <freedomrfox@gmail.com>2017-09-10 20:57:46 +0300
commit7aad0b503ca478b6c5c144a7a4e922f1d51e0e72 (patch)
treefc55150865c108645f7474dd28e3620800907613
parentText output py script (diff)
downloadGSE-7aad0b503ca478b6c5c144a7a4e922f1d51e0e72.tar.gz
GSE-7aad0b503ca478b6c5c144a7a4e922f1d51e0e72.tar.bz2
GSE-7aad0b503ca478b6c5c144a7a4e922f1d51e0e72.zip
Preliminary py functions
-rwxr-xr-xscripts/pyfunctions/preliminary.py73
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/pyfunctions/preliminary.py b/scripts/pyfunctions/preliminary.py
new file mode 100755
index 0000000..7aa435d
--- /dev/null
+++ b/scripts/pyfunctions/preliminary.py
@@ -0,0 +1,73 @@
+#!/usr/bin/env python3.6
+
+# Gentoo check function
+def _is_gentoo():
+ from subprocess import call
+
+ _dist_check = call("grep ^NAME= /etc/*release | awk -F '=' '{print $2}' | grep -q Gentoo", stdout=None, stderr=None, shell=True)
+
+ del call
+
+ if _dist_check == 0:
+ del _dist_check
+ return 0
+ else:
+ return 1
+
+# Check for superuser privileges
+def _is_su():
+ from subprocess import call
+
+ _super_u = call("if [[ $(echo $UID) == 0 ]]; then exit 0; else exit 1; fi", stdout=None, stderr=None, shell=True)
+
+ del call
+
+ if _super_u == 0:
+ del _super_u
+ return 1
+ else:
+ return 1
+
+
+# Simple shell call
+def _shell():
+ from gseout import e_report
+ from os import environ
+
+ active_shell = environ['SHELL']
+
+ e_report("Calling " + active_shell + ", please exit to resume script")
+
+ import time
+ time.sleep(3)
+
+ from subprocess import call
+
+ call([active_shell], stdout=None, stderr=None, shell=True)
+ e_report("Proceeding")
+
+ del e_report, time, call, active_shell, environ
+
+# Simple clear screen function
+def _clear():
+ from os import system
+ system("clear")
+
+def _parameter_error():
+ from gseout import die
+ from os import system
+ die("""
+ [ FATAL ]
+
+ If this message is printed while using the Maim Menu
+ That means essential files are altered or something bad is happening.
+
+ Please run a health-check from the ~Main Menu~ and a Version check first.
+ If you see this again after the health/version check, please submit a bug report
+ and stop using the program, or data loss may occur.
+
+ Exiting...
+ """)
+
+
+