-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcompile_targets.py
More file actions
executable file
·109 lines (91 loc) · 3.51 KB
/
compile_targets.py
File metadata and controls
executable file
·109 lines (91 loc) · 3.51 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
#!/usr/bin/python3
import os
import json
import argparse
os.environ['MAKEHUMAN2TOOL'] = str(True)
from core.environ import UserEnvironment
from core.importfiles import TargetASCII
if __name__ == '__main__':
# get environment parameters (standardmesh)
#
dirname = os.path.abspath(os.path.dirname(__file__))
os.chdir(dirname)
systemhome = os.path.join(dirname,"data", "target")
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)
userhome = os.path.join(conf["path_home"], "data")
parser = argparse.ArgumentParser(description="Compile targets to binary form (usually works interactive)")
parser.add_argument("base", type=str, nargs='?', help="if mentioned, targets of a different base mesh will be compiled, otherwise " + mesh)
parser.add_argument("-s", action="store_true", help="compile system space targets")
parser.add_argument("-f", "--file", type=str, help="compile only this file")
if userhome 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()
if args.file:
at = TargetASCII()
dest = os.path.join(args.file, "compressedtargets.npz")
at.compressAllTargets(args.file, dest, 1)
exit(0)
space = None
if args.u:
if userspace is None:
print ("No user space found")
exit (2)
space = userspace
if args.s:
space = systemspace
if args.base:
test = os.path.join(conf["path_home"], "data", "base", args.base)
if not os.path.isdir(test):
print (args.base + " demands a directory called " + test)
print ("Directory does not exist, Aborted.")
exit (20)
mesh = args.base
userspace = os.path.join(userhome, "target", mesh)
userspace_con = os.path.join(userhome, "contarget", mesh)
systemspace = os.path.join(systemhome, mesh)
print (userspace, systemspace)
# no decision, ask user
#
if space is None:
print("[1] User space: " + userspace)
print(" + : " + userspace_con)
print("\n[2] System space: " + systemspace)
okay = False
while not okay:
line = input('\nEnter 1, 2 or a to abort: ')
if line == "a":
exit (0)
if line == "1":
space = [userspace, userspace_con]
okay = True
if line == "2":
space = [systemspace]
okay = True
for elem in space:
print ("Compile targets in: " + elem)
dest = os.path.join(elem, "compressedtargets.npz")
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
for elem in space:
at = TargetASCII()
dest = os.path.join(elem, "compressedtargets.npz")
at.compressAllTargets(elem, dest, 1)