Closed ix- closed 4 months ago
rayoptics/gui/appcmds.py l88 checks for parts and fails, as the check tries to access the second element in a tuple that only has one element. `
rayoptics/gui/appcmds.py
la4966, info = open_model("./la4966.zmx", info=True) <<< /tmp/ray-optics/./lib64/python3.11/site-packages/rayoptics/gui/appcmds.py:88, in open_model(file_url, info, post_process_imports, kwargs) <<< 86 else: <<< 87 # if we're importing another program's file, collect import info <<<---> 88 if len(file_url_pth.parts) > 0 and file_url_pth.parts[1] == 'www.photonstophotos.net': <<< 89 opm, import_info = obench.read_obench_url(file_url, kwargs) <<< <<< IndexError: tuple index out of range`
Passing a full path (multiple parts) works: `
la4966, info = open_model("/tmp/ray-optics/la4966.zmx", info=True) `
la4966, info = open_model("/tmp/ray-optics/la4966.zmx", info=True)
`
I recommend using try: ... except: ... instead of if: ... else: ....
try: ... except: ...
if: ... else: ...
Cheers, -ix
Hi @ix-, Thanks for the report and the suggested fix. I'd already "fixed" problems with this code several times so I went in a different but direct way to address the problem. Thanks, Mike
rayoptics/gui/appcmds.py
l88 checks for parts and fails, as the check tries to access the second element in a tuple that only has one element. `Passing a full path (multiple parts) works: `
I recommend using
try: ... except: ...
instead ofif: ... else: ...
.Cheers, -ix