/
app.py
executable file
·45 lines (39 loc) · 1.21 KB
/
app.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
import sys, os
from src.normal import resizeImageDir, resizeImageCollectioneDir, coverImageDirToJSON, legoJson2Pickle
from src.main import main
# RUN_SHORT_CUT = "resizeImageCollectioneDir"
def print_usage():
print ("".join((
"python app.py <cmd>\n",
"<cmd>\n",
"\thelp : print this message\n",
"\trun : run project\n",
'\tresizeImageCollectioneDir <input_dir> : BJ4\n',
"\tcoverImageDirToJSON <input_dir>: BJ4\n",
"\tlegoJson2Pickle: BJ4\n"
)))
if __name__ == '__main__':
# import pdb; pdb.set_trace()
args = sys.argv[1:]
# args[0] = RUN_SHORT_CUT
if not args:
print_usage()
sys.exit(-1)
if args[0] == "help":
print_usage()
elif args[0] == "run":
main()
elif args[0] == "resizeImageCollectioneDir":
if len(args) < 2:
print_usage()
print('Not enough argments')
sys.exit(-1)
resizeImageCollectioneDir(args[1], "output/")
elif args[0] == "coverImageDirToJSON":
if len(args) < 2:
print_usage()
print('Not enough argments')
sys.exit(-1)
coverImageDirToJSON(args[1], "output/alldata.json")
elif args[0] == "legoJson2Pickle":
legoJson2Pickle("output/alldata.json", 'output/alphdata.pkl')