-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmango-installer.py
More file actions
379 lines (379 loc) · 11.7 KB
/
mango-installer.py
File metadata and controls
379 lines (379 loc) · 11.7 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
###MANGO-INSTALLER-0.0.1.0###
'''
'''
title='''
__ __
| \/ |Development 0123190046
| \ / | __ _ _ __ __ _ ___
| |\/| |/ _` | '_ \ / _` |/ _ \
| | | | (_| | | | | (_| | (_) |
|_| |_|\__,_|_| |_|\__, |\___/
______________________/ | V.3
|________________________| BET
'''
'''
Hello User! Welcome to the Mango source code. Credits can be found either below or embedded with the code they are crediting.
Thanks for using Mango!
'''
import time
def rai_prep(coremod,linux):
print("Requesting Mangocore from github...")
try:
update = urllib.request.Request('https://raw.githubusercontent.com/SimLoads/mango/mango-tools/mango-core.py')
response = urllib.request.urlopen(update)
newcode = response.read()
master = newcode.decode()
except:
print("Failed to connect.")
print("Please connect to the\ninternet and try again.")
time.sleep(5)
exit()
with open('mangocore.py', 'w', newline='') as core:
if coremod == True:
print("Core modification allowed")
if linux == True:
core.write(master)
core.close()
time.sleep(1)
os.system("sed -i '1i##MOD##' mangocore.py")
if linux == False:
core.write("'##MOD##'\n")
core.close()
time.sleep(1)
with open('mangocore.py', 'a', newline='') as corex:
corex.write(master)
corex.close()
core.close()
else:
core.write(master)
core.close()
print("Created mangocore.py")
try:
update = urllib.request.Request('https://raw.githubusercontent.com/SimLoads/mango/mango-tools/mangomanual')
response = urllib.request.urlopen(update)
newcode = response.read()
master = newcode.decode()
except:
print("Failed to connect.")
print("Please connect to the\ninternet and try again.")
time.sleep(5)
exit()
with open('mangomanual.py', 'w', newline='') as tool:
tool.write(master)
tool.close()
print("Script created.")
print("Launching...")
try:
os.startfile("mangomanual.py")
except:
pass
exit()
def clrs():
import platform
import os
if not "Windows" in (platform.platform()):
os.system("clear")
os.system("printf '\e[8;34;34t'")
else:
os.system("cls")
os.system("@mode con cols=34 lines=34")
def clrslo():
import platform
import os
if not "Windows" in (platform.platform()):
os.system("clear")
os.system("printf '\e[8;34;34t'")
print(title)
else:
os.system("cls")
os.system("@mode con cols=34 lines=34")
print(title)
def setup(use_title,reinstall,coremod,rai):
if rai == True:
print("Attempting RAI...")
print("Determining OS...")
if "Windows" in (platform.platform()):
linux = False
else:
linux = True
if linux == True:
if use_title == True:
os.system("clear")
if linux == False:
if use_title == True:
os.system("cls")
if use_title == True:
print(title)
print("Preparing Mango...")
import sys
print("Sys import")
import shutil
print("Shutil Import")
import urllib.request
print("Urllib.request Import")
if rai == False:
if not os.path.exists("mangotools"):
os.mkdir("mangotools")
print("Created mangotools")
else:
print("Skipped directory creation")
if rai == False:
os.chdir("mangotools")
print("Changed Directory")
if rai == False:
if not os.path.exists("__init__.py"):
os.system("echo '' >> __init__.py")
print("Created __init__.py")
else:
print("Skipped module prep")
print("A seperate script will be created\nto use Mango.")
rai_prep(coremod,linux)
if not os.path.exists("mangocore"):
print("Requesting tools from github...")
try:
update = urllib.request.Request('https://raw.githubusercontent.com/SimLoads/mango/mango-tools/mango-core.py')
response = urllib.request.urlopen(update)
newcode = response.read()
master = newcode.decode()
except:
print("Failed to connect.")
print("Please connect to the\ninternet and try again.")
time.sleep(1)
exit()
with open('mangocore.py', 'w', newline='') as core:
if coremod == True:
print("Core modification allowed")
if linux == True:
core.write(master)
core.close()
time.sleep(1)
os.system("sed -i '1i##MOD##' mangocore.py")
if linux == False:
core.write("'##MOD##'\n")
core.close()
time.sleep(1)
with open('mangocore.py', 'a', newline='') as corex:
corex.write(master)
corex.close()
core.close()
else:
core.write(master)
core.close()
print("Created mangocore.py")
try:
update_C = urllib.request.Request('https://raw.githubusercontent.com/SimLoads/mango/mango-tools/mangoconfig.py')
response_C = urllib.request.urlopen(update_C)
newcode_C = response_C.read()
master_C = newcode_C.decode()
except:
print("Failed to connect.")
time.sleep(1)
exit()
with open('mangoconfig.py', 'w', newline='') as config:
config.write(master_C)
config.close()
print("Created mangoconfig.py")
os.chdir('..')
sys.path.insert(0, 'mangotools')
print("Preparing for import...")
try:
from mangotools import mangocore
except:
print("Failed import!")
print("Restart installation.")
time.sleep(1)
exit()
print("Imported Mango Core")
pause = True
print("Testing Mango Core...")
try:
mangocore.core_test()
except:
print("Test failed. Restart installation.")
time.sleep(1)
exit()
print("Testing Mango Configure...")
try:
from mangotools import mangoconfig
except:
print("Failed import!")
print("Restart installation.")
time.sleep(1)
exit()
try:
mangoconfig.config_test()
except:
print("Test failed. Restart installation.")
time.sleep(1)
exit()
else:
pass
if reinstall == True:
print("Module reinstall finished.")
else:
print("Module install finished.")
print("Finalizing...")
print("Creating mango.py...")
try:
update_C = urllib.request.Request('https://raw.githubusercontent.com/SimLoads/mango/mango-tools/mangoauto.py')
response_C = urllib.request.urlopen(update_C)
newcode_C = response_C.read()
master_C = newcode_C.decode()
except:
print("Failed to connect.")
time.sleep(1)
exit()
with open('mango.py', 'w') as config:
config.write(master_C)
config.close()
clrslo()
print("Mango has finished installing.")
print("1} Launch dedicated script")
print("2} Add Mango to $PATH")
print("3} Exit without launching")
launchin = input("")
if launchin == "1":
print("Launching...")
if linux == True:
print("Please use 'python3 mango.py'\nto launch.")
time.sleep(1)
exit()
try:
os.startfile("mango.py")
except:
pass
exit()
if launchin == "2":
print("This feature is currently in heavy development.")
print("Come back later!")
print("Mango will now close.")
time.sleep(5)
exit()
else:
print("Exiting...")
time.sleep(2)
exit()
def install_set():
global linux_set
global core_set_mod
global core_rai_mod
clrslo()
print("")
try:
if core_set_mod == True:
print("1} Allow core modification *")
else:
print("1} Allow core modification")
except:
print("1} Allow core modification")
try:
if core_rai_mod == True:
print("2} Restricted Access Install *")
else:
print("2} Restricted Access Install")
except:
print("2} Restricted Access Install")
print("8} Ready to install")
print("9} Discard changes")
x = input("")
if x == "1":
try:
if core_set_mod == True:
core_set_mod = False
print("Core modification disallowed.")
time.sleep(1)
install_set()
except:
core_set_mod = True
print("Core modification allowed.")
time.sleep(1)
install_set()
if x == "2":
try:
if core_rai_mod == True:
core_rai_mod = False
print("RAI Disabled.")
time.sleep(1)
install_set()
except:
core_rai_mod = True
print("RAI Enabled.")
time.sleep(1)
install_set()
if x == "8":
use_title = True
reinstall = False
try:
if core_set_mod == True:
coremod = True
if core_set_mod == False:
coremod = False
except:
coremod = False
try:
if core_rai_mod == True:
rai = True
if core_rai_mod == False:
rai = False
except:
rai = False
setup(use_title,reinstall,coremod,rai)
if x == "9":
print("Installing with default settings...")
use_title = False
reinstall = False
coremod = False
rai = False
setup(use_title,reinstall,coremod,rai)
else:
install_set()
import os
import time
import urllib.request
reinstall = False
import platform
import shutil
clrs()
if not os.path.exists("mangotools"):
while True:
clrs()
print(title)
print("----------------------------------")
print("Welcome to Mango!")
print("1} Install now")
print("2} Modify installation")
print("3} Exit")
choice = input("")
if choice == "1":
use_title = True
coremod = False
rai = False
setup(use_title,reinstall,coremod,rai)
break
if choice == "2":
install_set()
break
else:
continue
else:
while True:
clrs()
print(title)
print("Mango is already installed!")
print("Reinstall Mango? [y/n]")
reinstall = input("")
if reinstall == "y":
if not "Windows" in (platform.platform()):
linux = True
os.system("clear")
else:
linux = False
os.system("cls")
shutil.rmtree('mangotools', ignore_errors=True)
install_set()
break
else:
print("Exiting...")
time.sleep(1)
exit()
break