-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_targets.py
executable file
·77 lines (65 loc) · 2.35 KB
/
compile_targets.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
#!/usr/bin/python3
import os
import json
import argparse
from core.importfiles import UserEnvironment, TargetASCII
if __name__ == '__main__':
# get environment parameters (standardmesh)
#
release_info = os.path.join("data", "makehuman2_version.json")
if os.path.isfile(release_info):
with open(release_info, 'r') as f:
release = json.load(f)
mesh = release["standardmesh"]
uenv = UserEnvironment()
uenv.GetPlatform()
conffile = uenv.GetUserConfigFilenames()[0]
userspace = None
if os.path.isfile(conffile):
with open(conffile, 'r') as f:
conf = json.load(f)
userspace = os.path.join(conf["path_home"], "data", "target", mesh)
systemspace = os.path.join(os.path.dirname(os.path.abspath(__file__)),"data", "target", mesh)
parser = argparse.ArgumentParser(description="Compile targets to binary form (usually works interactive)")
parser.add_argument("-s", action="store_true", help="compile system space targets")
if userspace is not None:
parser.add_argument("-u", action="store_true", help="compile user space instead of system space")
parser.add_argument("-n", action="store_true", help="compile non interactive")
args = parser.parse_args()
space = None
if args.u:
if userspace is None:
print ("No user space found")
exit (2)
space = userspace
if args.s:
space = systemspace
# no decision, ask user
#
if space is None:
print("[1] User space: " + userspace)
print("[2] System space: " + systemspace)
okay = False
while not okay:
line = input('Enter 1, 2 or a to abort: ')
if line == "a":
exit (0)
if line == "1":
space = userspace
okay = True
if line == "2":
space = systemspace
okay = True
dest = os.path.join(space, "compressedtargets.npz")
print ("Compile targets in: " + space)
print ("Destination file is: " + dest)
if args.n is False:
okay = False
while not okay:
line = input('Enter a to abort, c to compress: ')
if line == "a":
exit (0)
if line == "c":
okay = True
at = TargetASCII()
at.compressAllTargets(space, dest, 1)