183 | | self.logdebug("Converting input datas to TIFF...") |
184 | | result = None |
185 | | self.infile.seek(0) |
186 | | (handle, filename) = tempfile.mkstemp(".tmp", "pkpgcounter") |
187 | | os.close(handle) |
188 | | command = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%i -sOutputFile="%s" -' % (dpi, filename) |
189 | | try : |
190 | | child = popen2.Popen4(command) |
191 | | try : |
192 | | data = self.infile.read(pdlparser.MEGABYTE) |
193 | | while data : |
194 | | child.tochild.write(data) |
195 | | data = self.infile.read(pdlparser.MEGABYTE) |
196 | | child.tochild.flush() |
197 | | child.tochild.close() |
198 | | except (IOError, OSError), msg : |
199 | | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |
200 | | |
201 | | child.fromchild.close() |
202 | | try : |
203 | | child.wait() |
204 | | except OSError, msg : |
205 | | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |
206 | | |
207 | | result = inkcoverage.getPercents(filename) |
208 | | finally : |
209 | | try : |
210 | | os.remove(filename) |
211 | | except OSError : |
212 | | pass |
213 | | return result |
| 183 | command = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%i -sOutputFile="%s" -' % (dpi, fname) |
| 184 | child = popen2.Popen4(command) |
| 185 | try : |
| 186 | data = self.infile.read(pdlparser.MEGABYTE) |
| 187 | while data : |
| 188 | child.tochild.write(data) |
| 189 | data = self.infile.read(pdlparser.MEGABYTE) |
| 190 | child.tochild.flush() |
| 191 | child.tochild.close() |
| 192 | except (IOError, OSError), msg : |
| 193 | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |
| 194 | |
| 195 | child.fromchild.close() |
| 196 | try : |
| 197 | child.wait() |
| 198 | except OSError, msg : |
| 199 | raise pdlparser.PDLParserError, "Problem during conversion to TIFF : %s" % msg |