- Timestamp:
- 12/13/04 21:39:46 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r1977 r1980 22 22 PyKota NEWS : 23 23 24 - 1.21alpha13 : 25 26 - Added a --debug command line option to pkpgcounter, so 27 that people may see what really happens, and what will 28 be available in the future :-) 29 24 30 - 1.21alpha12 : 25 31 -
pykota/trunk/pykota/pdlanalyzer.py
r1940 r1980 22 22 # 23 23 # $Log$ 24 # Revision 1.45 2004/12/13 20:39:46 jalet 25 # Added a --debug command line option to pkpgcounter, for people interested 26 # in seeing what happens, and what will be available in the future :-) 27 # 24 28 # Revision 1.44 2004/11/17 15:10:31 jalet 25 29 # Fixed Epson Stylus Photo problem in software accounting … … 186 190 class PostScriptAnalyzer : 187 191 """A class to parse PostScript documents.""" 188 def __init__(self, infile ) :192 def __init__(self, infile, debug=0) : 189 193 """Initialize PostScript Analyzer.""" 194 self.debug = debug 190 195 self.infile = infile 191 196 self.copies = 1 … … 193 198 def throughGhostScript(self) : 194 199 """Get the count through GhostScript, useful for non-DSC compliant PS files.""" 200 if self.debug : 201 sys.stderr.write("Internal parser sucks, using GhostScript instead...\n") 195 202 self.infile.seek(0) 196 203 command = 'gs -sDEVICE=bbox -dNOPAUSE -dBATCH -dQUIET - 2>&1 | grep -c "%%HiResBoundingBox:" 2>/dev/null' … … 252 259 class PDFAnalyzer : 253 260 """A class to parse PDF documents.""" 254 def __init__(self, infile ) :261 def __init__(self, infile, debug=0) : 255 262 """Initialize PDF Analyzer.""" 263 self.debug = debug 256 264 self.infile = infile 257 265 … … 266 274 class ESCP2Analyzer : 267 275 """A class to parse ESC/P2 documents.""" 268 def __init__(self, infile ) :276 def __init__(self, infile, debug=0) : 269 277 """Initialize ESC/P2 Analyzer.""" 278 self.debug = debug 270 279 self.infile = infile 271 280 … … 356 365 357 366 358 def __init__(self, infile ) :367 def __init__(self, infile, debug=0) : 359 368 """Initialize PCL Analyzer.""" 369 self.debug = debug 360 370 self.infile = infile 361 371 … … 566 576 pagecount = endgfx 567 577 568 #for pnum in range(pagecount) : 569 # # if no number of copies defined, take the preceding one else the one set before any page else 1. 570 # page = pages.get(pnum, pages.get(pnum - 1, pages.get(0, { "copies" : 1, "mediasource" : "Main", "mediasize" : "Default", "mediatype" : "Plain", "orientation" : "Portrait"}))) 571 # print "%s*%s*%s*%s*%s" % (page["copies"], page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"]) 578 if self.debug : 579 for pnum in range(pagecount) : 580 # if no number of copies defined, take the preceding one else the one set before any page else 1. 581 page = pages.get(pnum, pages.get(pnum - 1, pages.get(0, { "copies" : 1, "mediasource" : "Main", "mediasize" : "Default", "mediatype" : "Plain", "orientation" : "Portrait"}))) 582 print "%s*%s*%s*%s*%s" % (page["copies"], page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"]) 572 583 573 584 return pagecount … … 614 625 } 615 626 616 def __init__(self, infile ) :627 def __init__(self, infile, debug=0) : 617 628 """Initialize PCLXL Analyzer.""" 629 self.debug = debug 618 630 self.infile = infile 619 631 self.endianness = None … … 873 885 copies = page["copies"] 874 886 self.pagecount += (copies - 1) 875 # print "%s*%s*%s*%s*%s" % (copies, page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"]) 887 if self.debug : 888 print "%s*%s*%s*%s*%s" % (copies, page["mediatype"], page["mediasize"], page["orientation"], page["mediasource"]) 876 889 877 890 return self.pagecount … … 879 892 class PDLAnalyzer : 880 893 """Generic PDL Analyzer class.""" 881 def __init__(self, filename ) :894 def __init__(self, filename, debug=0) : 882 895 """Initializes the PDL analyzer. 883 896 … … 886 899 supports read() and seek(). 887 900 """ 901 self.debug = debug 888 902 self.filename = filename 889 903 try : … … 914 928 else : 915 929 try : 916 size = pdlhandler(self.infile ).getJobSize()930 size = pdlhandler(self.infile, self.debug).getJobSize() 917 931 finally : 918 932 self.closeFile() … … 968 982 (sdata.find("LANGUAGE = Postscript") != -1))) or \ 969 983 (sdata.find("%!PS-Adobe") != -1) : 984 if self.debug : 985 sys.stderr.write("%s is a PostScript file\n" % str(self.filename)) 970 986 return 1 971 987 else : … … 978 994 ((sdata[:128].find("\033%-12345X") != -1) and (sdata.upper().find("LANGUAGE=PDF") != -1)) or \ 979 995 (sdata.find("%PDF-") != -1) : 996 if self.debug : 997 sys.stderr.write("%s is a PDF file\n" % str(self.filename)) 980 998 return 1 981 999 else : … … 988 1006 sdata.startswith("\033%8\033") or \ 989 1007 (sdata.find("\033%-12345X") != -1) : 1008 if self.debug : 1009 sys.stderr.write("%s is a PCL3/4/5 file\n" % str(self.filename)) 990 1010 return 1 991 1011 else : … … 998 1018 ((sdata.find("LANGUAGE=PCLXL") != -1) or \ 999 1019 (sdata.find("LANGUAGE = PCLXL") != -1))) : 1020 if self.debug : 1021 sys.stderr.write("%s is a PCLXL (aka PCL6) file\n" % str(self.filename)) 1000 1022 return 1 1001 1023 else : … … 1008 1030 sdata.startswith("\n\033@") or \ 1009 1031 sdata.startswith("\0\0\0\033\1@EJL") : # ESC/P Raster ??? Seen on Stylus Photo 1284 1032 if self.debug : 1033 sys.stderr.write("%s is an ESC/P2 file\n" % str(self.filename)) 1010 1034 return 1 1011 1035 else : … … 1046 1070 1047 1071 totalsize = 0 1048 for arg in sys.argv[1:] : 1072 debug = 0 1073 minindex = 1 1074 if sys.argv[1] == "--debug" : 1075 minindex = 2 1076 debug = 1 1077 for arg in sys.argv[minindex:] : 1049 1078 try : 1050 parser = PDLAnalyzer(arg )1079 parser = PDLAnalyzer(arg, debug) 1051 1080 totalsize += parser.getJobSize() 1052 1081 except PDLAnalyzerError, msg : -
pykota/trunk/pykota/version.py
r1974 r1980 22 22 # 23 23 24 __version__ = "1.21alpha1 2_unofficial"24 __version__ = "1.21alpha13_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""