Closed JamesParrott closed 8 months ago
This issue is not caused by sDNA_GH. The test code below fails to call out to any external executable from Rhino 8.5, neither from CPython nor IronPython
import subprocess
import re
import os
from collections import OrderedDict
def run(*args, **kwargs):
# return subprocess.check_output(*args, **kwargs)
# return str(subprocess.call(*args, **kwargs))
return str(subprocess.check_call(*args, **kwargs))
names = ('python',) #, 'node', 'git', 'hadolint', 'yak')
def test_progs(progs, args):
for prog in progs:
command = r'%s %s' % (prog, ' '.join('"%s"' % arg
for arg in args
)
)
try:
print(run(command).rstrip())
except subprocess.CalledProcessError as e:
print('Error. command: %s \nError info: %s' % (command, vars(e)))
PATH = os.getenv('path')
exes = OrderedDict()
for name in names:
for dir_ in PATH.split(';'):
path = os.path.join(dir_, '%s.exe' % name)
if os.path.isfile(path):
exes[name] ='"%s"' % path
break # inner loop
test_progs(names, ['--version'])
print()
test_progs(exes.values(), ['--version'])
print()
working_dir = r'%appdata%\McNeel\Rhinoceros\8.0\scripts'
args = []
for arg in ('hello_world.py',
'hello_world.js',
'Dockerfile'
):
file_ = os.path.join(working_dir, arg)
if os.path.isfile(file_):
args.append(file_)
assert args
test_progs([exes['python']],args[:1])
# test_progs([exes['node']],args[1:2])
# test_progs([exes['hadolint']],args[2:])
produces:
Running: python "--version"
Python 3.11.4
Running: node "--version"
v18.16.0
Running: hadolint "--version"
Haskell Dockerfile Linter 2.12.0
()
Running: "C:\Users\drjam\AppData\Local\Programs\Python\Python311\python.exe" "--version"
Python 3.11.4
Running: "C:\Program Files\nodejs\node.exe" "--version"
v18.16.0
Running: "C:\Program Files (x86)\Hadolint\hadolint.exe" "--version"
Haskell Dockerfile Linter 2.12.0
()
Running: "C:\Program Files\nodejs\node.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.js"
Hello, World!
Running: "C:\Program Files (x86)\Hadolint\hadolint.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\Dockerfile"
Running: "C:\Users\drjam\AppData\Local\Programs\Python\Python311\python.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.py"
Error. Info: {'returncode': 1, 'cmd': '"C:\\Users\\drjam\\AppData\\Local\\Programs\\Python\\Python311\\python.exe" "C:\\Users\\drjam\\AppData\\Roaming\\McNeel\\Rhinoceros\\8.0\\scripts\\hello_world.py"', 'output': ''}
Running: python "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.py"
Error. Info: {'returncode': 1, 'cmd': 'python "C:\\Users\\drjam\\AppData\\Roaming\\McNeel\\Rhinoceros\\8.0\\scripts\\hello_world.py"', 'output': ''}
Where as from the command line (as in the zip file):
Running: python "--version"
b'Python 3.11.4'
Running: node "--version"
b'v18.16.0'
Running: hadolint "--version"
b'Haskell Dockerfile Linter 2.12.0'
Running: "C:\Users\drjam\AppData\Local\Programs\Python\Python311\python.exe" "--version"
b'Python 3.11.4'
Running: "C:\Program Files\nodejs\node.exe" "--version"
b'v18.16.0'
Running: "C:\Program Files (x86)\Hadolint\hadolint.exe" "--version"
b'Haskell Dockerfile Linter 2.12.0'
Running: "C:\Program Files\nodejs\node.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.js"
b'Hello, World!'
Running: "C:\Program Files (x86)\Hadolint\hadolint.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\Dockerfile"
b''
Running: "C:\Users\drjam\AppData\Local\Programs\Python\Python311\python.exe" "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.py"
b'Bonjour le Monde!'
Running: python "C:\Users\drjam\AppData\Roaming\McNeel\Rhinoceros\8.0\scripts\hello_world.py"
b'Bonjour le Monde!'
The shapefiles weren't deleted so the same command ran just fine from the command line: