[Radiance-general] Re: translate UNIX command into Windows command

David Smith dbs176 at gmail.com
Tue Jul 27 12:08:38 PDT 2010


> However, I recommend the Python "subprocess" module as an alternative.
> Subprocess avoids many of the problems of quoting by converting Python
> lists to command argument lists.


I agree that the subprocess module is the way to go.

Not to turn this into a Python discussion, but convenience functions are
very handy:




#! /bin/python

import subprocess

def execute(cmd):
    #print cmd
    p = subprocess.Popen(cmd, shell=True)
    s = os.waitpid(p.pid, 0)
    return s

def execute2(cmd):
    p = subprocess.Popen(cmd, shell=True, bufsize=1024,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
    (child_stdin, child_stdout) = (p.stdin, p.stdout)
    return (child_stdin, child_stdout)

#test Radiance calls
rpict_command = "rpict model.oct > image.hdr"
gensky_command = "gensky 4 1 12 -c"

execute(rpict_command)
f_in,f_out = execute2(gensky_command)
gensky_output = f_out.read()





--Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://radiance-online.org/pipermail/radiance-general/attachments/20100727/8b76d67c/attachment.html


More information about the Radiance-general mailing list