[IronPython] opening an exe with iron python

Bruce Bromberek bruce.bromberek at gmail.com
Thu Jan 20 16:11:08 CET 2011

If you are committed to Ironpython, then you can use the the .NET calls

from System.Diagnostics import Process
path = r"C:/Program Files/Chaos Group/V-Ray/Maya 2011 for x64/bin"
execfile = "vrimg2exr.exe"
CMDARGS = "%s %s" % (infile,outfile)

command = "%s\\%s"% (path,execfile)
print "starting command"
proc = Process()
proc.StartInfo.FileName = command
proc.StartInfo.Arguments = CMDARGS
print "Done"

or I have used subprocess to send data in a stream and capture the output.
 It is possible to do the same thing with System.Diagnostics but I don't
have an example.

import subprocess as S

mycmd = "XSLTools\\msxsl.exe - FixEncodedMessage.xslt -o %s" % Response
output = S.Popen(mycmd,stdin=S.PIPE,shell=True).communicate(xml)[0]

If you problem is that the IronPython engine you are using in Deadline
 doesn't have the standard python modules, you could always build the
modules you need into a DLL on another machine, place the DLL out on the
render farm and use

import clr
import subprocess

to build the DLL you would can use the pyc.py script that comes with
Ironpython.  I typically create a subfolder in my project, copy the Standard
Lib modules I need (and their dependencies) and use this script from the
commandline to generate the DLL.

#Compile Folder into DLL
import clr
from System import IO
from System.IO.Path import Combine

def walk(folder):
for file in IO.Directory.GetFiles(folder):
yield file
for folder in IO.Directory.GetDirectories(folder):
for file in walk(folder):
yield file

folder = IO.Path.GetDirectoryName(__file__)
print folder

myfiles = list(walk(IO.Path.Combine(folder, 'STDLIB')))

clr.CompileModules(Combine(folder,".\StdLib.dll"), *myfiles)

> The existing script is works like this (I'm sure this is error loaded and
> obvious n00b script, so any input would be hugely appreciated):
> converter = subprocess.Popen([r"C:/Program Files/Chaos Group/V-Ray/Maya
> for x64/bin/vrimg2exr.exe", inFile, outFile],stdout=subprocess.PIPE)
> print converter.communicate()[0]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20110120/4371ec10/attachment.html>

More information about the Ironpython-users mailing list