Skip to content

Commit 2b8195e

Browse files
authored
Utilities Updates (#34)
* interactive bindings prototype. * Sort of working. Images won't work. * Get flask app installed properly and fix up module cmd line. * Move Python GLSL renderer utilitiy into repo. Add some dependent resources: sphere.obj, and irradience HDR. * Setup package to allow GLSL stock renderer to use package resources Update package resources. Add snaps from WIP interactive debug/conversion util.
1 parent 2492b35 commit 2b8195e

20 files changed

Lines changed: 27717 additions & 23 deletions
203 KB
Loading
85.3 KB
Loading
68.4 KB
Loading
51.4 KB
Loading

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "materialxusd"
7-
version = "0.25.05.1"
7+
version = "0.25.08"
88
description = "Utilities for MaterialX and USD"
99
authors = [
1010
{ name="Bernard Kwok", email="kwokcb@gmail.com" },
@@ -29,4 +29,5 @@ materialxusd = "materialxusd.__main__:main"
2929
[tool.setuptools.packages.find]
3030
where = ["source"]
3131
[tool.setuptools.package-data]
32-
"materialxusd.data" = ["*.*"]
32+
"materialxusd.data" = ["**/*"]
33+
"materialxusd.templates" = ["**/*"]

source/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

source/materialxusd/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.1'
1+
__version__ = "0.25.08"

source/materialxusd/__main__.py

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
import sys, os
22
import subprocess
3+
import argparse
34

45
def main() -> int:
56
'''
67
Main entry point for running commands in the package.
78
'''
8-
argCount = len(sys.argv)
9-
if argCount < 2:
10-
print('No arguments provided. Use -h or --help for help.')
11-
return 1
12-
if sys.argv[1] == '-h' or sys.argv[1] == '--help':
13-
print('Usage: python -m materialxusd <command> [options] where command is: m2u, pmtlx, or getmtlx')
9+
parser = argparse.ArgumentParser(description='MaterialX / USD command line utilities.', add_help=False)
10+
parser.add_argument('option', nargs='?', help='Possible options: m2u, pmtlx, getmtlx, webpage, mxgl')
11+
args, remaining_args = parser.parse_known_args()
1412

15-
# Check if the command is valid
16-
cmdArgs = sys.argv[1:]
17-
if cmdArgs[0] == 'm2u':
18-
cmdArgs[0] = 'mtlx2usd.py'
19-
elif cmdArgs[0] == 'pmtlx':
20-
cmdArgs[0] = 'preprocess_mtlx.py'
21-
elif cmdArgs[0] == 'getmtlx':
22-
cmdArgs[0] = 'mtlxdownload.py'
13+
option = args.option
14+
# If no option provided or help requested for main command, show help
15+
if option is None or option in ['-h', '--help']:
16+
parser.add_help = True
17+
parser.print_help()
18+
return 0
19+
20+
if option == 'm2u':
21+
cmd = 'mtlx2usd.py'
22+
elif option == 'pmtlx':
23+
cmd = 'preprocess_mtlx.py'
24+
elif option == 'getmtlx':
25+
cmd = 'mtlxdownload.py'
26+
elif option == 'mxgl':
27+
cmd = 'mxglslrender.py'
28+
elif option == 'webpage':
29+
cmd = 'flask_app.py'
2330
else:
24-
print('Unknown command specified:', cmdArgs[0])
31+
print(f'Unknown option specified: {option}')
32+
parser.add_help = True
33+
parser.print_help()
2534
return 1
2635

27-
# Build the command
36+
# Build command with remaining arguments (for non-Flask commands)
37+
cmdArgs = [cmd] + remaining_args
2838
cmd = ' '.join(cmdArgs)
2939
packageLocation = os.path.dirname(__file__)
3040
cmd = sys.executable + ' ' + packageLocation + '/' + cmd
3141
print('Running command:', cmd)
3242

33-
# Run the command
34-
return subprocess.call(cmd, shell=True)
43+
# Run the command and allow breaking with Ctrl+C / Cmd-C
44+
try:
45+
return subprocess.call(cmd, shell=True)
46+
except KeyboardInterrupt:
47+
print("\nProcess interrupted by user.")
48+
return 130 # Standard exit code for interrupted process
3549

3650
if __name__ == '__main__':
3751
sys.exit(main())
72.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)