| 102 | self.textlist = textlist |
| 103 | |
| 104 | def go(self, machine, workdir): |
| 105 | |
| 106 | local = machine in ('localhost', '127.0.0.1') |
| 107 | |
| 108 | def worker_do(cmd): |
| 109 | if DEBUG: print '[[%s]]' % machine, |
| 110 | if local: |
| 111 | # do stuff on this machine |
| 112 | do(cmd, howfarback=1) |
| 113 | else: |
| 114 | # do stuff on a remote machine |
| 115 | do('ssh %s "%s"' % (machine, cmd), howfarback=1) |
| 116 | |
| 117 | if povray_pretty: |
| 118 | povray_options = '+A -V -D +X' |
| 119 | else: |
| 120 | povray_options = '-A +Q0 -V -D +X' |
| 121 | |
| 122 | worker_do('mkdir -p ' + workdir) |
| 123 | # worker_do('find %s -type f -exec rm -f {} \;' % workdir) |
| 124 | |
| 125 | # |
| 126 | # Create a shell script to run on the worker machine |
| 127 | # |
| 128 | global _which_povray_job |
| 129 | self.scriptname = 'povray_job_%08d.sh' % _which_povray_job |
| 130 | _which_povray_job += 1 |
| 131 | video_aspect_ratio = 4.0 / 3.0 |
| 132 | w2 = int(video_aspect_ratio * self.pheight) |
| 133 | jpg = (self.povfmt % self.povmin)[:-4] + '.jpg' |
| 134 | tgalist = '' |
| 135 | povlist = '' |
| 136 | scriptlines = [ ] |
| 137 | scriptlines.append('cd %s' % workdir) |
| 138 | # Worker machine renders a bunch of pov files to tga files |
| 139 | for i in range(self.povmin, self.povmax_plus_one): |
| 140 | pov = self.povfmt % i |
| 141 | povlist += ' ' + pov |
| 142 | tga = pov[:-4] + '.tga' |
| 143 | tgalist += ' ' + tga |
| 144 | scriptlines.append('povray +I%s +O%s +FT %s +W%d +H%d 2>/dev/null' % |
| 145 | (pov, tga, povray_options, self.pwidth, self.pheight)) |
| 146 | # Worker machine averages the tga files into one jpeg file |
| 147 | scriptlines.append('convert -average %s -crop %dx%d+%d+0 -geometry %dx%d! %s' % |
| 148 | (tgalist, w2, self.pheight, (self.pwidth - w2) / 2, |
| 149 | self.ywidth, self.yheight, jpg)) |
| 150 | # Worker cleans up the pov and tga files, no longer needed |
| 151 | scriptlines.append('rm -f %s %s' % |
| 152 | (povlist, tgalist)) |
| 153 | if DEBUG: |
| 154 | for line in scriptlines: |
| 155 | print machine + '>>> ' + line |
| 156 | shellscript = open(os.path.join(self.srcdir, self.scriptname), 'w') |
| 157 | for line in scriptlines: |
| 158 | shellscript.write(line + '\n') |
| 159 | shellscript.close() |
| 160 | |
| 161 | # |