forked from nfrechette/acl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Small fixes to compressor when outputing to a stat file.
Added an acl_compressor python script to traverse a directory hierarchy and output stats.
- Loading branch information
1 parent
15eb63a
commit d9461e4
Showing
3 changed files
with
111 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
import sys | ||
|
||
def parse_argv(): | ||
options = {} | ||
options['acl'] = "" | ||
options['stat'] = "" | ||
|
||
for i in range(1, len(sys.argv)): | ||
value = sys.argv[i] | ||
|
||
# TODO: Strip trailing '/' or '\' | ||
if value.startswith('-acl='): | ||
options['acl'] = value[5:].replace('"', '') | ||
|
||
if value.startswith('-stat='): | ||
options['stat'] = value[6:].replace('"', '') | ||
|
||
return options | ||
|
||
def print_usage(): | ||
print('Usage: python acl_compressor.py -acl=<path to directory containing ACL files> -stat=<path to output directory for stats>') | ||
|
||
if __name__ == "__main__": | ||
options = parse_argv() | ||
|
||
debug_exe_path = './x64/Debug/acl_compressor.exe' | ||
release_exe_path = './x64/Release/acl_compressor.exe' | ||
|
||
debug_exe_timestamp = os.path.getmtime(debug_exe_path) | ||
release_exe_timestamp = os.path.getmtime(release_exe_path) | ||
|
||
if release_exe_timestamp >= debug_exe_timestamp: | ||
latest_exe_path = release_exe_path | ||
else: | ||
latest_exe_path = debug_exe_path | ||
|
||
acl_dir = options['acl'] | ||
stat_dir = options['stat'] | ||
|
||
if not os.path.exists(acl_dir) or not os.path.isdir(acl_dir): | ||
print('ACL input directory not found: {}'.format(acl_dir)) | ||
print_usage() | ||
sys.exit(1) | ||
|
||
if not os.path.exists(stat_dir): | ||
os.makedirs(stat_dir) | ||
|
||
if not os.path.isdir(stat_dir): | ||
print('The output stat argument must be a directory') | ||
print_usage() | ||
sys.exit(1) | ||
|
||
for (dirpath, dirnames, filenames) in os.walk(acl_dir): | ||
stat_dirname = dirpath.replace(acl_dir, stat_dir) | ||
|
||
for filename in filenames: | ||
if not filename.endswith('.acl.js'): | ||
continue | ||
|
||
acl_filename = os.path.join(dirpath, filename) | ||
stat_filename = os.path.join(stat_dirname, filename.replace('.acl.js', '_stats.txt')) | ||
|
||
if not os.path.exists(stat_dirname): | ||
os.makedirs(stat_dirname) | ||
|
||
cmd = '{} -acl="{}" -stats="{}"'.format(latest_exe_path, acl_filename, stat_filename) | ||
cmd = cmd.replace('/', '\\') | ||
|
||
print('Compressing {}...'.format(acl_filename)) | ||
os.system(cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,4 +384,4 @@ def convert_file(fbx_filename, acl_filename, zip): | |
if result: | ||
sys.exit(0) | ||
else: | ||
sys.exit(1) | ||
sys.exit(1) |