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

R Fritz RFritz at lbl.gov
Tue Jul 27 10:08:59 PDT 2010


You've got what are probably typos; the following will probably work:
> rtrace_command = 'rtrace -I -ab 1 -h -w -oov -u- scene.oct < sensor.pts | \
> rcalc -e "$1=$1;$2=$2;$3=$3;$4=179*(.265*$4+.670*$5+.065*$6)" \
> > result.dat'

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. One way of doing what you want might 
be:

> # Untested code
> 
> from subprocess import Popen, communicate, PIPE
> 
> rtproc = Popen(
> 	"rtrace -I -ab 1 -h -w -oov -u- scene.oct".split(),
> 	stdin=PIPE, stdout=PIPE, universal_newlines=True)
> 
> rcproc = Popen(
> 	['rcalc', '-e', '$1=$1;$2=$2;$3=$3;$4=179*(.265*$4+.670*$5+.065*$6)'],
> 	stdin=rtproc.stdout, stdout=PIPE)
> 
> sensor_points = open('sensor.pts', 'U')
> (results,errors) = rcproc.communicate(sensor_points)
> sensor_points.close()
> if rtproc.returncode != 0 or rcproc.returncode != 0:
> 	# report errors here
> # if it worked, results will be in 'results'

-- 
Randolph Fritz • RFritz at lbl.gov
Environmental Energy Technologies Division • Lawrence Berkeley Labs


On 2010-07-27 05:50:19 -0700, Ji Zhang said:

>  Dear Thomas and Radiance experts, one more question:
> 
> If I want to execute this rtrace command in windows via python, should 
> I use the tri-quotation symbol? 
> 
> Is the following python script correct?
> 
> ##################################################################################
import 
> 
> os
> 
> rtrace_command = ''rtrace -I -ab 1 -h -w -oov -u- scene.oct < sensor.pts > " +\
>                                """rcalc -e 
> "$1=$1;$2=$2;$3=$3;$4=179*(.265*$4+.670*$5+.065*$6)" > result.dat"""
> 
> os.system(rtrace_command)
> ##################################################################################


Thanks!

Ji



On 
> 
> Tue, Jul 27, 2010 at 7:50 PM, Thomas Bleicher 
> <tbleicher at googlemail.com> wrote:
> Ji
> 
> On Tue, Jul 27, 2010 at 10:05 AM, Ji Zhang 
> <hope.zh at gmail.com> wrote:
> > I've tried the following in Windows, but it doesn't seem to work:
> >
> > rtrace -I -ab 1 -h -w -oov -u- scene.oct < sensor.pts > rcalc -e
> > '$1=$1;$2=$2;$3=$3;$4=179*(.265*$4+.670*$5+.065*$6)' > result.dat
> 
> The Windows command prompt doesn't understand single quotes. Use
> double quotes for the "rcalc -e" expression and it should work:
> 
> rtrace -I -ab 1 -h -w -oov -u- scene.oct < sensor.pts > rcalc -e
> "$1=$1;$2=$2;$3=$3;$4=179*(.265*$4+.670*$5+.065*$6)" > result.dat
> 
> 
> Thomas
> 
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-general
> _______________________________________________
> Radiance-general mailing list
> Radiance-general at radiance-online.org
> http://www.radiance-online.org/mailman/listinfo/radiance-general





More information about the Radiance-general mailing list