Show
Ignore:
Timestamp:
10/17/06 09:41:55 (18 years ago)
Author:
jerome
Message:

Improved ink accounting by allowing several commands to be launch to convert to TIFF in case one of them fails.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pkpgcounter/trunk/pkpgpdls/plain.py

    r422 r428  
    3333class Parser(pdlparser.PDLParser) : 
    3434    """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                     ]   
    5038    def isValid(self) :     
    5139        """Returns True if data is plain text, else False.