-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.py
More file actions
150 lines (126 loc) · 4.28 KB
/
start.py
File metadata and controls
150 lines (126 loc) · 4.28 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
import sys, os, subprocess
def clear():
os.system("cls" if os.name is "nt" else "clear")
def handleExit():
try:
sys.exit(0)
except SystemExit:
os._exit(0)
def buildEnvFiles(defaultParam):
subprocess.check_call(f"python ./scripts/build-env-files.py {defaultParam}", shell=True)
return
def stopRedis():
subprocess.check_call("python ./scripts/poke-redis.py down", shell=True)
return
def stopMongo():
subprocess.check_call("python ./scripts/poke-mongo.py down", shell=True)
return
def startRedis(newVolumeParam):
stopRedis()
subprocess.check_call(f"python ./scripts/poke-redis.py up {newVolumeParam}", shell=True)
return
def startMongo(newVolumeParam):
stopMongo()
subprocess.check_call(f"python ./scripts/poke-mongo.py up {newVolumeParam}", shell=True)
return
def startPokeQueryBackend():
subprocess.check_call("start cmd.exe /k \"python ./scripts/run-poke-query.py\"", shell=True)
return
def openFrontendAppInBrowser():
os.system("start http://localhost:5173")
return
def startPokeQueryFrontend():
subprocess.check_call("start cmd.exe /k \"python ./scripts/run-frontend.py\"", shell=True)
return
def openInVsCode():
subprocess.check_call("python ./scripts/open-repo-vscode.py\"", shell=True)
return
def openInVisualStudio():
subprocess.Popen("python ./scripts/open-pokequery-solution.py", shell=True)
return
def createPokeDataVolume():
subprocess.Popen("python ./scripts/create-poke-data-volume.py", shell=True)
return
def runPokeLoader():
subprocess.check_call("python ./scripts/run-poke-loader.py", shell=True)
return
def lowerInput(prompt):
return input(prompt).lower()
def handleInput(input):
displayOptions = True
match input:
case "1":
createPokeDataVolume()
buildEnvFiles("--use-default")
startRedis("--new-volume")
startMongo("--new-volume")
runPokeLoader()
startPokeQueryBackend()
startPokeQueryFrontend()
openFrontendAppInBrowser()
case "2":
createPokeDataVolume()
case "3":
buildEnvFiles("--use-default")
case "4":
buildEnvFiles("")
case "5":
startMongo("")
case "6":
startMongo("--new-volume")
case "7":
stopMongo()
case "8":
startRedis("")
case "9":
startRedis("--new-volume")
case "10":
stopRedis()
case "11":
runPokeLoader()
case "12":
startPokeQueryBackend()
case "13":
startPokeQueryFrontend()
case "14":
openFrontendAppInBrowser()
case "15":
openInVsCode()
case "16":
openInVisualStudio()
case "x":
handleExit()
case _:
print(f"Unknown Input Value: {input}")
displayOptions = False
return mainMenu(displayOptions)
def mainMenu(displayOptions):
if (displayOptions):
print("Please select from the following options [1-16, X] or Ctrl + C to Exit.")
print("1. Start Everything From Scratch")
print("2. Create PokeData Volume")
print("3. Build/Rebuild .env Files With Default Values")
print("4. Build/Rebuild .env Files With User Defined Values")
print("5. Start Mongo Container")
print("6. Start Mongo Container With New Volume")
print("7. Stop Mongo Container")
print("8. Start Redis Container")
print("9. Start Redis Container With New Volume")
print("10. Stop Redis Container")
print("11. Run PokeLoader (Load data into Redis/Mongo)")
print("12. Start PokeQuery Backend")
print("13. Start poke-query Frontend")
print("14. Open Frontend App In Browser")
print("15. Open Repo in VS Code")
print("16. Open PokeQuery.sln")
print("X. Exit/Quit")
handleInput(lowerInput("Input Value: "))
return
def main():
clear()
mainMenu(True)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
handleExit()