Changeset 1622

Show
Ignore:
Timestamp:
07/22/04 15:49:51 (20 years ago)
Author:
jalet
Message:

Added support for binary PostScript? through GhostScript? if native DSC
compliant PostScript? analyzer doesn't find any page. This is much
slower though, so native analyzer is tried first.

Location:
pykota/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r1604 r1622  
    287287#                 pkpgcounter is a command line tool which is 
    288288#                 part of PyKota and which can handle both 
    289 #                 DSC compliant PostScript, PCL5, PCL6 (aka PCLXL) 
     289#                 DSC compliant or binary PostScript, PCL5, PCL6 (aka PCLXL) 
    290290#                 and PDF documents. More file formats will be added 
    291291#                 in the future, as time permits. 
  • pykota/trunk/FAQ

    r1578 r1622  
    7878    Page Description Language. 
    7979     
    80     PyKota natively understands PostScript, PCL5, PCLXL (aka PCL6) 
    81     and PDF. More PDLs will be added in the future. However you can  
    82     always plug your own PDL analyzer in PyKota. 
     80    PyKota natively understands DSC compliant PostScript, PCL5,  
     81    PCLXL (aka PCL6) and PDF. Support for Binary PostScript is 
     82    done through GhostScript. More PDLs will be added in the future.  
     83    However you can always plug your own PDL analyzer in PyKota. 
    8384           
    8485  * I've got a great number of users. How can I automatically 
  • pykota/trunk/LICENSE

    r1257 r1622  
    2929    Then follow the instructions in the section labeled "Getting a Copy of the CVS Repository".  
    3030 
    31   * Clients who purchased an **Official PyKota Package** can directly access to "the tarballs HERE":/software/PyKota/tarballs . 
     31  * Clients who purchased an **Official PyKota Package** can directly access to "the tarballs HERE": 
     32http://www.librelogiciel.com/software/PyKota/tarballs . 
    3233                
    3334Why no tarball is available for free : 
     
    6364    * Electronic form : 
    6465 
    65       * You pay me any amount of money starting at **15$ (US Dollars)** 
     66      * You pay me any amount of money starting at **20$ (US Dollars)** 
    6667 
    6768      * Then I send you the latest **PyKota 'OFFICIAL'** tarball,  
  • pykota/trunk/man/pkpgcounter.1

    r1575 r1622  
    1414\fBpkpgcounter\fP is a convenience script provided by pykota that attempts 
    1515to count the number of pages in a DSC compliant PostScript, PDF, PCL5 or  
    16 PCL6 (aka PCLXL) document. This may be of use 
    17 as an external accounter as defined in /etc/pykota/pykota.conf, since currently 
    18 \fBpkpgcounter\fP is the smarter software accounter included with PyKota. 
     16PCL6 (aka PCLXL) document. Binary PostScript is also supported through  
     17GhostScript. This may be of use as an external accounter as defined in  
     18/etc/pykota/pykota.conf, since currently \fBpkpgcounter\fP is the smarter  
     19software accounter included with PyKota. 
    1920 
    2021\fBpkpgcounter\fP with no argument reads the job's data from stdin, and prints 
  • pykota/trunk/NEWS

    r1611 r1622  
    2222PyKota NEWS : 
    2323 
     24    - 1.19alpha35 : 
     25     
     26        - Generic PDL analyzer now supports Binary PostScript documents 
     27          in addition to DSC compliant ones. 
     28         
    2429    - 1.19alpha34 : 
    2530     
  • pykota/trunk/pykota/pdlanalyzer.py

    r1599 r1622  
    2222# 
    2323# $Log$ 
     24# Revision 1.26  2004/07/22 13:49:51  jalet 
     25# Added support for binary PostScript through GhostScript if native DSC 
     26# compliant PostScript analyzer doesn't find any page. This is much 
     27# slower though, so native analyzer is tried first. 
     28# 
    2429# Revision 1.25  2004/07/10 14:06:36  jalet 
    2530# Fix for Python2.1 incompatibilities 
     
    108113import tempfile 
    109114import mmap 
     115import popen2 
    110116     
    111117KILOBYTE = 1024     
     
    125131        """Initialize PostScript Analyzer.""" 
    126132        self.infile = infile 
    127          
    128     def getJobSize(self) :     
     133        
     134    def throughGhostScript(self) : 
     135        """Get the count through GhostScript, useful for non-DSC compliant PS files.""" 
     136        self.infile.seek(0) 
     137        command = 'gs -sDEVICE=bbox -dNOPAUSE -dBATCH -dQUIET - 2>&1 | grep -c "%%HiResBoundingBox:" 2>/dev/null' 
     138        child = popen2.Popen4(command) 
     139        try : 
     140            data = self.infile.read(MEGABYTE)     
     141            while data : 
     142                child.tochild.write(data) 
     143                data = self.infile.read(MEGABYTE) 
     144            child.tochild.flush() 
     145            child.tochild.close()     
     146        except (IOError, OSError), msg :     
     147            raise PDLAnalyzerError, "Problem during analysis of Binary PostScript document." 
     148             
     149        pagecount = 0 
     150        try : 
     151            pagecount = int(child.fromchild.readline().strip()) 
     152        except (IOError, OSError, AttributeError, ValueError) : 
     153            raise PDLAnalyzerError, "Problem during analysis of Binary PostScript document." 
     154        child.fromchild.close() 
     155         
     156        try : 
     157            retcode = child.wait() 
     158        except OSError, msg :     
     159            raise PDLAnalyzerError, "Problem during analysis of Binary PostScript document." 
     160        return pagecount 
     161         
     162    def natively(self) : 
    129163        """Count pages in a DSC compliant PostScript document.""" 
     164        self.infile.seek(0) 
    130165        pagecount = 0 
    131166        for line in self.infile.xreadlines() :  
     
    133168                pagecount += 1 
    134169        return pagecount 
     170         
     171    def getJobSize(self) :     
     172        """Count pages in PostScript document.""" 
     173        return self.natively() or self.throughGhostScript() 
    135174         
    136175class PDFAnalyzer : 
  • pykota/trunk/pykota/version.py

    r1611 r1622  
    2222# 
    2323 
    24 __version__ = "1.19alpha34_unofficial" 
     24__version__ = "1.19alpha35_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/README

    r1612 r1622  
    6969          This is completely configurable. 
    7070           
    71         - Supports DSC compliant PostScript, PDF, PCL5, and 
    72           PCLXL (aka PCL6) printers natively for software  
     71        - Supports DSC compliant and binary PostScript, PDF, PCL5,  
     72          and PCLXL (aka PCL6) printers natively for software  
    7373          accounting methods. More formats to come. 
    7474