-
Notifications
You must be signed in to change notification settings - Fork 1
/
manage.py
47 lines (38 loc) · 1.12 KB
/
manage.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
import sys
import os
import subprocess
argv = sys.argv
name = argv[0]
command = argv[1].lower()
helpmsg = """
command: python3 manage.py {command}
accept agruments: "build", "server", "rm-{file name}", "rm-all"
e.g:
- build and train data: python3 manage.py build
- run server: python3 manage.py server
- remove cache file: python3 manage.py rm-{file name}
- remove all cache data: python3 manage.py rm-all
"""
def main():
if command == "help":
print(helpmsg)
return
if command == "build":
subprocess.check_output(["python3", "app/searcher/feature.py"])
return
if command == "server":
subprocess.check_output(["python3", "app/searcher/index.py"])
return
if "rm" in command:
filename = command[3:]
if filename == "all":
os.system("rm app/cache/*")
return
path = "app/cache/" + filename + ".pkl"
os.system("rm " + path)
return
print("Invalid command.")
print(helpmsg)
if __name__ == "__main__":
# print(name, command)
main()