Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
365 lines (356 loc) · 11.4 KB
/
Copy pathmain.py
File metadata and controls
365 lines (356 loc) · 11.4 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
password='a'
theme='blue'
apps=["Terminal","TicTacToe","Python","Firefox","Wikipedia","Settings","MyFiles"]
rapps=["Terminal","Tictactoe","Python","Firefox","Wikipedia","Settings","Myfiles"]
gameboard={"A1":"- ","A2":"- ","A3":"- ","B1":"- ","B2":"- ","B3":"- ","C1":"- ","C2":"- ","C3":"- "} #For TicTacToe
from termcolor import cprint
cprint("Loading proccess started",theme,attrs=['bold','underline'])
cprint("Please wait for loading to complete for the best results in Py OS",theme)
from replit import db as DB
from os import *
from random import randint as random
from time import sleep
import wikipedia
from tkinter import *
from tkinter import filedialog
import tkinter
import webbot
system('pip install webbot')
colors=['Red', 'Yellow', 'Green', 'Cyan', 'Blue', 'Magenta', 'White']
#list1.sort()
system("clear")
cprint("Loading proccess complete!",theme,attrs=['bold','underline'])
cprint("Now ready to run Py OS",theme)
sleep(1)
system("clear")
def openfile():
name= filedialog.askopenfilename()
print("Click the directory to open : "+name)
Label(main, text="File selected : ", font = ("Arial","10")).pack()
Label(main, text=name, font = ("Arial","15")).pack()
Label(main, text="\nUse the console to open the file", font = ("Arial","10")).pack()
error_msg="Error!"
def Myfiles():
main = Tk()
main.geometry("300x250")
main.configure(bg='white')
main.title("MyFiles")
Label(main, text="Click the following to select a file - after you will be able to open it with the console :", font = ("Arial","10"), pady="5", padx="5").pack()
Button(main,text="Select file", pady="4", padx="6", command=openfile,bg="darkblue",font=("Verdana", 15), fg="white").pack()
Label(main, text="\n", font = ("Arial","10")).pack()
main.mainloop()
def print(t):
cprint(t,theme,attrs=['bold'])
def Wikipedia():
while 1==1:
system('clear')
global res
cprint("Search Wikipedia",theme,attrs=['bold'],end=" ")
cprint("(type 'Back' to leave)",theme,end=" ")
cprint(":",theme,attrs=['bold'])
res = input(" ")
print("")
if res.upper()=="BACK":
system('clear')
break
try:
summary = wikipedia.summary(res, sentences=4)
cprint(summary,theme)
print("")
input("Press enter to do another search ")
except:
cprint("No results found.",'red',attrs=['bold'])
sleep(2)
system('clear')
def Terminal():
system('clear')
cprint("Terminal interpreter/compiler",theme,attrs=['bold'])
print("")
cprint('Type "Back" to leave',theme)
print("")
list=[]
while 1==1:
x=input("$ ")
if x.lower()=="back":
system('clear')
break
if x=="clear":
list.clear()
system("clear")
y="$ "+x
list.append(y)
for i in list:
cprint(i,theme)
system(x)
def Python():
system('clear')
system('python3')
system('clear')
def Chrome():
system('clear')
try:
web = webbot.Browser()
web.go_to("https://google.com")
except:
system('clear')
cprint("Uh Oh! An error took place. Unable to open Chrome",'red',attrs=['bold'])
sleep(2)
def Firefox():
system("clear")
try:
cprint("Press Ctrl+C in the Console to exit Firefox",theme,attrs=['bold'])
print("")
system("firefox")
except:
system('clear')
cprint("Uh Oh! An error took place. Unable to open Firefox",'red',attrs=['bold'])
def Tictactoe():
while 1==1:
displayBoard()
print("Player 1's turn :")
p1=input(" ")
p1=p1.upper()
check=0
for var in gameboard.keys():
if var==p1:
check=1
if (not(check==1)):
print("Please enter a valid area :")
p1=input(" ")
check=0
for var in gameboard.keys():
if var==p1:
check=1
if (not(check==1)):
print("Player 1's turn skipped")
else:
if gameboard[p1]=="- ":
gameboard[p1]="X "
else:
print("Place taken (Player 1's turn was skipped)")
if lefttoright("X ")==1:
break
displayBoard()
print("Player 2's turn :")
p2=input(" ")
p2=p2.upper()
check=0
for var in gameboard.keys():
if var==p2:
check=1
if (not(check==1)):
print("Please enter a valid area :")
p2=input(" ")
check=0
for var in gameboard.keys():
if var==p2:
check=1
if (not(check==1)):
print("Player 2's turn skipped")
else:
if gameboard[p2]=="- ":
gameboard[p2]="O "
else:
print("Place taken (Player 2's turn was skipped)")
if lefttoright("O ")==1:
break
def displayBoard(): #For TicTacToe
system('clear')
print(" 1 2 3")
print("A "+gameboard["A1"]+gameboard["A2"]+gameboard["A3"])
print("B "+gameboard["B1"]+gameboard["B2"]+gameboard["B3"])
print("C "+gameboard["C1"]+gameboard["C2"]+gameboard["C3"])
print("")
def lefttoright(player): #For TicTacToe
co=1
lefttoright=0
for var in gameboard.values():
if ((gameboard["A1"]==player)and((gameboard["A2"]==player)and(gameboard["A3"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["B1"]==player)and((gameboard["B2"]==player)and(gameboard["B3"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["C1"]==player)and((gameboard["C2"]==player)and(gameboard["C3"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["A1"]==player)and((gameboard["B1"]==player)and(gameboard["C1"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["A2"]==player)and((gameboard["B2"]==player)and(gameboard["C2"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["A3"]==player)and((gameboard["B3"]==player)and(gameboard["C3"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["A1"]==player)and((gameboard["B2"]==player)and(gameboard["C3"]==player))):
print("Player "+player+" has won")
return(1)
break
elif ((gameboard["A3"]==player)and((gameboard["B2"]==player)and(gameboard["C1"]==player))):
print("Player "+player+" has won")
return(1)
break
return("0")
def Login():
system('clear')
cprint("Password",theme,attrs=['bold'],end=" ")
cprint("(default is 'a')",theme,end=" ")
cprint(":",theme,attrs=['bold'])
if input(" ")=='a':
system('clear')
cprint("Correct Password Entered",theme,attrs=['bold'])
sleep(1)
Load()
Load()
cprint("Loading Complete!",theme,attrs=['bold'])
sleep(2)
else:
print("")
cprint("Incorrect Password Entered",'red',attrs=['bold'])
sleep(2)
LoginT()
def Login2():
system('clear')
cprint("Password",theme,attrs=['bold'],end=" ")
cprint("(default is 'a')",theme,end=" ")
cprint(":",theme,attrs=['bold'])
if input(" ")=='a':
system('clear')
cprint("Correct Password Entered",theme,attrs=['bold'])
sleep(1)
Load()
Load()
cprint("Loading Complete!",theme,attrs=['bold'])
sleep(2)
else:
print("")
cprint("Incorrect Password Entered",'red',attrs=['bold'])
sleep(2)
Login()
def Load():
system('clear')
cprint("Loading.",theme,attrs=['bold'])
sleep(0.3)
system('clear')
cprint("Loading..",theme,attrs=['bold'])
sleep(0.3)
system('clear')
cprint("Loading...",theme,attrs=['bold'])
sleep(0.3)
system('clear')
def Settings(password):
actions=["Change the password","Change password","Password", "Change the theme","Change theme","Theme"]
p=["Change the password","Change password","Password"]
t=["Change the theme","Change theme","Theme"]
system('clear')
cprint("Hello, Welcome to Settings",theme,attrs=['underline','bold'])
cprint("Settings is where you can customise Py OS - Make it your own.",theme)
print("")
cprint("What next?",theme,attrs=['underline','bold'])
cprint("Enter anything from the list below to edit it",theme)
print("")
cprint("- Change the password\n",theme,attrs=['bold'])
cprint("- Change theme\n",theme,attrs=['bold'])
cprint("What would you like to do?",theme,attrs=['bold'])
i=input(" ")
i=i.capitalize()
if i in actions:
if i in p:
system('clear')
cprint("Let's first verify that it's you",theme,attrs=['bold'])
cprint("Please enter your password to continue :",theme)
i=input(" ")
if i==password:
system('clear')
cprint("What would you like to change your password to?",theme,attrs=['bold'])
i=input(" ")
return(i)
system('clear')
cprint("Password set",theme,attrs=['bold'])
sleep(2)
system('clear')
cprint("The new password is '"+i+"'",theme,attrs=['bold'])
if i in t:
system('clear')
for i in colors:
cprint(i,i.lower(),attrs=['bold'])
print("")
cprint("What color would you like to change the theme to?",theme,attrs=['bold'])
i=input(" ")
i=i.capitalize()
if i in colors:
return(i)
system('clear')
cprint("Theme set.",theme,attrs=['bold'])
def firsttime(i):
if ((i.lower()=="yes")or(i.lower()=="yes.")):
system('clear')
cprint("Welcome to PyOS\n",theme,attrs=['bold','underline'])
cprint("PyOS is well - an OS. PyOS was created 100% by Aarush.\n\n",theme)
cprint("|",theme,end=" ", attrs=["bold"])
cprint("Note! :",attrs=['bold'],end=" ")
cprint("I Know You are New,")
input("\n\nPress enter to continue")
system('clear')
cprint("Advantages\n",theme,attrs=['bold','underline'])
cprint("PyOS is offline, fast and customisable. It has games, interpreters, search engines and more!\n",theme)
input("Press enter to continue")
system('clear')
cprint("Disadvantages\n",theme,attrs=['bold','underline'])
cprint("To think about it, No bugs or errors have been found in PyOS, so that doesn't really leave any disadvantage\n",theme)
input("Press enter to continue")
system('clear')
cprint("Your turn\n",theme,attrs=['bold','underline'])
cprint("It's time for you to try PyOS and see how all the things mentioned previously are true\n",theme)
cprint("Press enter to run PyOS",theme,attrs=['bold'],end="")
input("")
elif ((i.lower()=="no")or(i.lower()=="no.")):
Login()
else:
cprint("'"+i+"' is invalid. Please enter 'Yes','Yes.', 'No' or 'No.' to continue.",'red',attrs=['bold'])
sleep(4)
system('clear')
cprint("Is this your first time on Py OS?",theme,attrs=['bold','underline'])
cprint("If your new, you can see to help you use Py OS",theme)
i=input(" ")
firsttime(i)
system('clear')
cprint("Is this your first time on Py OS?",theme,attrs=['bold','underline'])
cprint("If your new, you can see a quick intro to Py OS ",theme)
i=input(" ")
firsttime(i)
while 1==1:
system('clear')
co=1
for AppName in apps:
cpr=AppName
cprint(cpr,theme)
co+=1
print("")
cprint("|",theme,end=" ", attrs=["bold"])
cprint("Tip! :",attrs=['bold'],end=" ")
cprint("This isn't case sensitive - even if you type 'PyThOn' it will open Python\n")
cprint("Which app would you like to open?",theme,attrs=['bold'])
i=input(" ")
i=i.capitalize()
if (not(i in rapps)):
print("")
cprint("Unknown app entered. Please enter one of the apps listed above",'red',attrs=['bold'])
sleep(2)
else:
if (not(i=="Settings")):
exec(i+"()")
else:
i=Settings(password)
a=i.capitalize()
if ((a==i) and (i in colors)):
theme=i.lower()
else:
password=i