Changeset 1686
- Timestamp:
- 08/31/04 01:10:25 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1683 r1686 22 22 PyKota NEWS : 23 23 24 - 1.20alpha4 : 25 26 - Added support for more ghostscript devices in ESC/P2 27 analyzer : stcolor, st800, escp, escpc are now supported. 28 24 29 - 1.20alpha3 : 25 30 -
pykota/trunk/pykota/pdlanalyzer.py
r1683 r1686 22 22 # 23 23 # $Log$ 24 # Revision 1.35 2004/08/30 23:10:24 jalet 25 # Improved the ESC/P2 analyzer so that more GhostScript devices are supported 26 # 24 27 # Revision 1.34 2004/08/27 09:08:22 jalet 25 28 # Improvement in PostScript parser to avoid being fooled by clever "students" … … 237 240 def getJobSize(self) : 238 241 """Counts pages in an ESC/P2 document.""" 239 # with G hostScript, at least, for each page there242 # with Gimpprint, at least, for each page there 240 243 # are two Reset Printer sequences (ESC + @) 241 marker = "\033@" 242 pagecount = 0 244 marker1 = "\033@" 245 pagecount1 = 0 246 247 # with other software or printer driver, we 248 # may prefer to search for "\r\n\fESCAPE" 249 # or "\r\fESCAPE" 250 marker2r = "\r\f\033" 251 marker2rn = "\r\n\f\033" 252 pagecount2 = 0 253 254 # and ghostscript's stcolor for example seems to 255 # output ESC + @ + \f for each page plus one 256 marker3 = "\033@\f" 257 pagecount3 = 0 258 259 # while ghostscript's escp driver outputs instead 260 # \f + ESC + @ 261 marker4 = "\f\033@" 262 pagecount4 = 0 263 243 264 for line in self.infile.xreadlines() : 244 pagecount += line.count(marker) 245 return int(pagecount / 2) 265 pagecount1 += line.count(marker1) 266 generic = line.count(marker2r) 267 if not generic : 268 generic = line.count(marker2rn) 269 pagecount2 += generic 270 pagecount3 += line.count(marker3) 271 pagecount4 += line.count(marker4) 272 273 if pagecount2 : 274 return pagecount2 275 elif pagecount3 > 1 : 276 return pagecount3 - 1 277 elif pagecount4 : 278 return pagecount4 279 else : 280 return int(pagecount1 / 2) 281 246 282 247 283 class PCLAnalyzer : … … 613 649 psyco.bind(PostScriptAnalyzer.getJobSize) 614 650 psyco.bind(PDFAnalyzer.getJobSize) 651 psyco.bind(ESCP2Analyzer.getJobSize) 615 652 psyco.bind(PCLAnalyzer.getJobSize) 616 653 psyco.bind(PCLXLAnalyzer.getJobSize) … … 715 752 """Returns 1 if data is ESC/P2, else 0.""" 716 753 if data.startswith("\033@") or \ 754 data.startswith("\033*") or \ 717 755 data.startswith("\n\033@") : 718 #data.startswith("\033*") or719 756 return 1 720 757 else : -
pykota/trunk/pykota/version.py
r1680 r1686 22 22 # 23 23 24 __version__ = "1.20alpha 3_unofficial"24 __version__ = "1.20alpha4_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/tests/runtest.sh
r1676 r1686 4 4 /bin/rm -f testsuite.* master2.ps 5 5 gunzip <master.ps.gz >master2.ps 6 for device in laserjet ljet3 ljet4 lj5gray lj5mono pxlmono pxlcolor pdfwrite pswrite psgray psmono psrgb epson epsonc eps9mid eps9high ; do6 for device in laserjet ljet3 ljet4 lj5gray lj5mono pxlmono pxlcolor pdfwrite pswrite psgray psmono psrgb epson epsonc eps9mid eps9high stcolor st800 escp escpc ; do 7 7 gs -dQUIET -dBATCH -dNOPAUSE -sOutputFile="testsuite.$device" -sDEVICE="$device" master2.ps ; 8 8 done