aboutsummaryrefslogtreecommitdiff
blob: 7aa435da8a96c2bed8a0f72188af6b0540327207 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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...
		""")