-
Notifications
You must be signed in to change notification settings - Fork 0
/
starter.py
173 lines (152 loc) · 6.29 KB
/
starter.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
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
import sys
import os
import json
import webbrowser
dirfolder = "_files"
pyscript = "_files/main.py"
setupfileno = "setup.json"
userpath = "%USERPROFILE%"
setupfile = "C:/Users/Public/PyPrompt/setup.json"
pyprompt = "Checking PyPrompt... not Found!"
filescheck = "Checking files... not found!"
programfile = "Checking program files... not found!"
setupdia = "Setup file... not found!"
setup1 = "Entering setup..."
print("------------PyPrompt------------")
print("PyPrompt will shortly begin after this!")
# Checking for the files
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
# Found the files
if base_path == base_path:
filescheck = "Checking files... found!"
print(filescheck)
# Checking for the PyPrompt script
usedfiles = os.path.join(base_path, pyscript)
if os.path.exists(usedfiles):
pyprompt = "Checking PyPrompt... found!"
else:
print("")
print("WARNING! starter.py didn't find PyPrompt!")
print("Without PyPrompt this program can't start! If you didn't know\n")
print("Troubleshot")
print("[1] = go to the Github page")
print("[2] = Give new location")
print("[3] = Ignore warning and contine")
print("[4] = Give up!")
cfpy = input("recovery> ")
if cfpy == "1":
print("We are going to open the Github page!")
print("https://github.com/Maxboiy/PyPrompt")
print("open? [y/n]")
agreepage = input("recovery/contine> ")
if agreepage == "y":
webbrowser.open("https://github.com/Maxboiy/PyPrompt")
if agreepage == "n":
print("Please restart this program!")
input("recovery/quit>")
ha_error
elif cfpy == "2":
print("WARNING: This is temporary and will not happen very time on boot")
print("Where to look:", usedfiles)
newlocation = input("recovery/location> ")
pyscript = newlocation
elif cfpy == "3":
print("Continuing...")
elif cfpy == "4":
print("Are you giving up?")
print("Never should you give up!\n")
print("Do you want me to open some inspirational music? [y/n]")
inspirationalmusic = input("recovery/give_up> ")
if inspirationalmusic == "y":
webbrowser.open("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
print("GOT YOU!!! HAHAHHAHAHAHA")
input("recovery/give_up/troll> ")
youvebeenrickrolled
if inspirationalmusic == "n":
print("Its sad to see you go! :,(")
input("recovery/quit> ")
goodbye
print(pyprompt)
# Checking for the files used by PyPrompt
useddir = os.path.join(base_path, dirfolder)
if os.path.exists(useddir):
programfile = "Checking program files... found!"
print(programfile)
# Checking for setup file
if os.path.exists(setupfile):
with open(setupfile, "r") as f:
data = json.load(f)
for setup in data["setup"]:
if setup["done"] == "True":
setupdia = "Setup file... found!"
setup1 = "Skipping setup..."
print(setupdia)
print(setup1)
else:
os.system("cls")
print("------------PyPrompt/Setup------------")
print("Welcome to PyPrompt!\n")
print("PyPrompt is an terminal recreation but in Python")
print("It might not have all the features as an normal terminal")
print("but hey! atleast it works... for the most part\n")
print("Press enter to contine.")
input("------------\033[0;30;47mContinue\033[0m------------")
os.system("cls")
print("------------PyPrompt/Setup------------")
print("Hello there! this start program creates an file which auto skips the setup")
print("But we want permission from you to know if we can save setup.json in the Public user folder.")
print("If you decline, you will have to do the setup everytime you start PyPrompt")
print("DIR >>", setupfile)
print()
print("[yes/no]")
permissionneed = input("Permission>")
if permissionneed == "yes":
os.system("cls")
print("------------PyPrompt/Setup------------")
print("Thank you! The file will be created once setup is completed.\n")
input("------------\033[0;30;47mContinue\033[0m------------")
elif permissionneed == "no":
print("------------PyPrompt/Setup------------")
print("The setup.json file will be saved in the temp folder!\n")
input("------------\033[0;30;47mContinue\033[0m------------")
os.system("cls")
print("------------PyPrompt/Setup/help------------")
print("1. Terminal in terminal")
print("Some commands are there own terminals, meaning they will have there own commands and doesn't work like the main terminal")
print("the commands that are there own terminal will have an (T) at the end of there name\n")
print("Type skip to skip this part!\n")
print("Try it out!\n")
while True:
print("Type run")
sample1 = input("pyprompt/sample1> ")
if sample1 == "run":
print("Goodjob! Your now inside the other terminal. But how do you get out?\n")
print("Type exit")
sample1_run = input("run\>")
if sample1_run == "exit":
break
else:
print(sample1_run, "does not work! ")
elif sample1 == "skip":
break
else:
print(sample1, "does not work!")
print("And thats the basics of the terminal commands")
print("Press enter to contine.")
input("------------\033[0;30;47mContinue\033[0m------------")
setupw = {"setup": [{"done": "True"}] }
if permissionneed == "yes":
permsave = os.path.join(userpath, setupfile)
if os.path.exists("C:/Users/Public/PyPrompt"):
with open(permsave, "w") as f:
json.dump(setupw, f)
else:
os.mkdir('C:/Users/Public/PyPrompt')
with open(permsave, "w") as f:
json.dump(setupw, f)
elif permissionneed == "no":
tempsave = os.path.join(useddir, setupfileno)
with open(tempsave, "w") as f:
json.dump(setupw, f)
os.system('%s %s' % ("python", usedfiles))
os.system("%s %s" % ("python", usedfiles))