-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
128 lines (97 loc) · 3.32 KB
/
main.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/python3.1
import os
import sys
import subprocess
sys.path.append("/opt/MeeShop/functions")
import dbc
from clean import clean
blue = '\033[96m'
red = '\033[31m'
reset = '\033[0m'
green = '\033[32m'
blink = '\033[5m'
yellow = '\033[33m'
cyan = '\033[1;36m'
def press_enter_to_exit():
input(" {}{}Press Enter to exit... {}".format(blink, cyan, reset))
sys.exit(1)
def main():
clean()
print(" Setting up workspace...\n")
try:
#folder = "."
folder = "/opt/MeeShop/.cache"
if not os.path.isdir(folder):
if os.path.isfile(folder):
os.remove(folder)
os.mkdir(folder)
os.chdir(folder)
except:
print(" {}Error while setting workspace...\n{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
print(" Testing internet connection...\n")
_ = subprocess.call("ping wunderwungiel.pl -c 1 > /dev/null 2>&1", shell=True)
if _ != 0:
print(" {}Failed to connect, check your internet connection.\n{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
print(" Building databases...\n")
db_creator = dbc.Db_creator()
if db_creator.error:
print(" {}Failed building databases...\n{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
for f in os.listdir("."):
if f.endswith(".deb"):
os.remove(f)
print(" Checking for Aegis-hack...\n")
if not os.path.isfile("/usr/bin/aegis-apt-get"):
print(" {}Aegis-install hack by CODeRUS needs to be installed.{}".format(red, reset))
print(" Get it here:")
print(" http://wunderwungiel.pl/MeeGo/apt-repo/pool/main/hack-installer_1.0.10_armel.deb")
print(" ")
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
print(" Importing necessary modules...\n")
try:
from first_menu import first_menu
import apt
except ImportError:
print(" {}Failed importing necessary modules...\n{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
print(" Testing dpkg lock state...\n")
result = apt.is_dpkg_locked()
if result:
print(" {}dpkg / apt-get is busy and locked...{}".format(red, reset))
print(" Close all dpkg / apt-get processes")
print(" and try again. You can also reboot phone.\n")
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
if not apt.is_repo_enabled():
print(" Adding MeeShop repository...\n")
result = apt.add_repo()
if result == "Error":
print(" {}Failed adding repository...\n{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
print(" Updating repositories...\n")
result = apt.update()
if result == "Error":
print(" {}Error updating repositories...{}".format(red, reset))
press_enter_to_exit()
else:
print(" {}Done!\n{}".format(green, reset))
while True:
first_menu()
clean()
if __name__ == "__main__":
main()