Changeset 428 for pkpgcounter/trunk
- Timestamp:
- 10/17/06 09:41:55 (18 years ago)
- Location:
- pkpgcounter/trunk/pkpgpdls
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/dvi.py
r415 r428 33 33 class Parser(pdlparser.PDLParser) : 34 34 """A parser for DVI documents.""" 35 totiffcommand = 'cat >%(fname)s && dvips -q -o - %(fname)s | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'35 totiffcommands = [ 'cat >%(fname)s && dvips -q -o - %(fname)s | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ] 36 36 def isValid(self) : 37 37 """Returns True if data is DVI, else False.""" -
pkpgcounter/trunk/pkpgpdls/oldpcl345.py
r426 r428 34 34 class Parser(pdlparser.PDLParser) : 35 35 """A parser for PCL3, PCL4, PCL5 documents.""" 36 totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 36 totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 37 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 38 ] 37 39 mediasizes = { # ESC&l####A 38 40 0 : "Default", -
pkpgcounter/trunk/pkpgpdls/pcl345.py
r426 r428 39 39 class Parser(pdlparser.PDLParser) : 40 40 """A parser for PCL3, PCL4, PCL5 documents.""" 41 totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 41 totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 42 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 43 ] 42 44 mediasizes = { # ESC&l####A 43 45 0 : "Default", -
pkpgcounter/trunk/pkpgpdls/pclxl.py
r426 r428 34 34 class Parser(pdlparser.PDLParser) : 35 35 """A parser for PCLXL (aka PCL6) documents.""" 36 totiffcommand = 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 36 totiffcommands = [ 'pcl6 -sDEVICE=pdfwrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 37 'pcl6 -sDEVICE=pswrite -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -sOutputFile=- - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 38 ] 37 39 mediasizes = { 38 40 0 : "Letter", -
pkpgcounter/trunk/pkpgpdls/pdf.py
r415 r428 43 43 class Parser(pdlparser.PDLParser) : 44 44 """A parser for PDF documents.""" 45 totiffcommand = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'45 totiffcommands = [ 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ] 46 46 def isValid(self) : 47 47 """Returns True if data is PDF, else False.""" -
pkpgcounter/trunk/pkpgpdls/pdlparser.py
r425 r428 23 23 24 24 import sys 25 import os 25 26 import popen2 26 27 … … 41 42 class PDLParser : 42 43 """Generic PDL parser.""" 43 totiffcommand = None # Default command to convert to TIFF44 totiffcommands = None # Default command to convert to TIFF 44 45 def __init__(self, infile, debug=0, firstblock=None, lastblock=None) : 45 46 """Initialize the generic parser.""" … … 89 90 Writes TIFF datas to the file named by fname. 90 91 """ 91 if self.totiffcommand : 92 commandline = self.totiffcommand % locals() 93 child = popen2.Popen4(commandline) 94 try : 92 if self.totiffcommands : 93 for totiffcommand in self.totiffcommands : 94 self.infile.seek(0) 95 error = False 96 commandline = totiffcommand % locals() 97 child = popen2.Popen4(commandline) 95 98 try : 96 data = self.infile.read(MEGABYTE) 97 while data : 98 child.tochild.write(data) 99 data = self.infile.read(MEGABYTE) 100 except (IOError, OSError), msg : 101 raise PDLParserError, "Problem during conversion to TIFF : %s" % msg 102 finally : 103 child.tochild.close() 104 child.fromchild.close() 105 106 try : 107 child.wait() 108 except OSError, msg : 109 raise PDLParserError, "Problem during conversion to TIFF : %s" % msg 99 try : 100 data = self.infile.read(MEGABYTE) 101 while data : 102 child.tochild.write(data) 103 data = self.infile.read(MEGABYTE) 104 except (IOError, OSError) : 105 error = True 106 finally : 107 child.tochild.close() 108 child.fromchild.close() 109 110 try : 111 child.wait() 112 except OSError : 113 error = True 114 115 if not os.path.exists(fname) : 116 error = True 117 elif not os.stat(fname).st_size : 118 error = True 119 else : 120 break # Conversion worked fine it seems. 121 self.logdebug("Command failed : %s" % repr(commandline)) 122 if error : 123 raise PDLParserError, "Problem during conversion to TIFF." 110 124 else : 111 125 raise PDLParserError, "Impossible to compute ink coverage for this file format." -
pkpgcounter/trunk/pkpgpdls/plain.py
r422 r428 33 33 class Parser(pdlparser.PDLParser) : 34 34 """A parser for plain text documents.""" 35 enscript = 'enscript --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 36 a2ps = 'a2ps --borders 0 --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' 37 def __init__(self, infile, debug=0, firstblock=None, lastblock=None) : 38 """Initialize the plain text parser.""" 39 pdlparser.PDLParser.__init__(self, infile, debug, firstblock, lastblock) 40 41 # Tries to detect is a plain text to PostScript command line tool is available 42 # and use the first one we find. 43 paths = os.environ.get("PATH", "/usr/local/bin:/usr/bin:/bin").split(os.pathsep) 44 for cmd in ("enscript", "a2ps") : 45 for path in paths : 46 if os.path.exists(os.path.join(path, cmd)) : 47 self.totiffcommand = getattr(self, cmd) 48 return 49 35 totiffcommands = [ 'enscript --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 36 'a2ps --borders 0 --quiet --portrait --no-header --columns 1 --output - | gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -', 37 ] 50 38 def isValid(self) : 51 39 """Returns True if data is plain text, else False. -
pkpgcounter/trunk/pkpgpdls/postscript.py
r415 r428 34 34 class Parser(pdlparser.PDLParser) : 35 35 """A parser for PostScript documents.""" 36 totiffcommand = 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -'36 totiffcommands = [ 'gs -sDEVICE=tiff24nc -dPARANOIDSAFER -dNOPAUSE -dBATCH -dQUIET -r%(dpi)i -sOutputFile="%(fname)s" -' ] 37 37 def isValid(self) : 38 38 """Returns True if data is PostScript, else False.""" -
pkpgcounter/trunk/pkpgpdls/tiff.py
r415 r428 33 33 class Parser(pdlparser.PDLParser) : 34 34 """A parser for TIFF documents.""" 35 totiffcommand = "cat >%(fname)s"35 totiffcommands = [ "cat >%(fname)s" ] 36 36 def isValid(self) : 37 37 """Returns True if data is TIFF, else False."""