Hey guys,
I’m trying to use subprocess to gather some information from one of our tools that needs to be run via cmd line within our shell.
I am running subprocess.Popen() from within a script called within Maya to do this.
Maya is running within our shell, that is setup via batch at Maya launch.
gameRoot=os.environ.get("GAME_ROOT") + '\ ools\\options'
_cmd=[r'python', 'import os', 'os.environ.copy()']
task = subprocess.Popen(_cmd, cwd=gameRoot, stdout=subprocess.PIPE) #shell=True,
task.wait()
I am finding as soon as I introduce the subprocess.PIPE to the mix I get a funky crash. Obviously I need the Pipe to retrieve the data I want.
Error: (6, ‘The handle is invalid’)
Traceback (most recent call last):
File “<maya console>”, line 1, in <module>
File “…\maya\2009\python\ssgtools\utils\ssgSubProc.py”, line 10, in ssgSubProcGetEnv
task = subprocess.Popen(_cmd, cwd=gameRoot, stdout=subprocess.PIPE) #shell=True,
File “C:\Program Files (x86)\Autodesk\Maya2009\bin\python25.zip\subprocess.py”, line 586, in init
errread, errwrite) = self._get_handles(stdin, stdout, stderr)
File “C:\Program Files (x86)\Autodesk\Maya2009\bin\python25.zip\subprocess.py”, line 699, in _get_handles
p2cread = self._make_inheritable(p2cread)
File “C:\Program Files (x86)\Autodesk\Maya2009\bin\python25.zip\subprocess.py”, line 744, in _make_inheritable
DUPLICATE_SAME_ACCESS)
WindowsError: (6, ‘The handle is invalid’)
My solution is to write the data to a file on disk as I have this option with the exe I need to use, then read that files contents in and use that, but it kinda defeats the point of being able to run a sub process and create a temp file using temp file then pull the data from that container.
any ideas? Its driving me nuts…