Changeset 532 for pkpgcounter/trunk
- Timestamp:
- 11/30/07 23:48:03 (17 years ago)
- Location:
- pkpgcounter/trunk/pkpgpdls
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pkpgcounter/trunk/pkpgpdls/lidil.py
r522 r532 73 73 unpack = struct.unpack 74 74 ejectpage = loadpage = 0 75 while True:76 header = self.infile.read(HEADERSIZE)77 if not header :78 break79 if (len(header) != HEADERSIZE) or (header[0] != "$") :80 # Invalid header or no Frame Sync byte.81 raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."82 try :75 try : 76 while True : 77 header = self.infile.read(HEADERSIZE) 78 if not header : 79 break 80 if (len(header) != HEADERSIZE) or (header[0] != "$") : 81 # Invalid header or no Frame Sync byte. 82 raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas." 83 83 (framesync, 84 84 cmdlength, … … 88 88 referencenumber, 89 89 datalength) = unpack(">BHBBBHH", header) 90 except struct.error :91 raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas."92 if packettype == PACKET_TYPE_COMMAND :93 if commandnumber == LDL_LOAD_PAGE :94 loadpage += 195 elif commandnumber == LDL_EJECT_PAGE :96 ejectpage += 197 self.infile.seek(cmdlength + datalength - len(header), 1) # relative seek90 if packettype == PACKET_TYPE_COMMAND : 91 if commandnumber == LDL_LOAD_PAGE : 92 loadpage += 1 93 elif commandnumber == LDL_EJECT_PAGE : 94 ejectpage += 1 95 self.infile.seek(cmdlength + datalength - len(header), 1) # relative seek 96 except struct.error : 97 raise pdlparser.PDLParserError, "This file doesn't seem to be valid Hewlett-Packard LIDIL datas." 98 98 99 99 # Number of page eject commands should be sufficient, -
pkpgcounter/trunk/pkpgpdls/zjstream.py
r522 r532 52 52 def getJobSize(self) : 53 53 """Computes the number of pages in a ZjStream document.""" 54 unpack = struct.unpack55 54 self.infile.seek(4, 0) # Skip ZJZJ/JZJZ header 56 55 startpagecount = endpagecount = 0 57 while True : 58 header = self.infile.read(16) 59 if not header : 60 break 61 try : 56 unpackHeader = self.unpackHeader 57 unpack = struct.unpack 58 try : 59 while True : 60 header = self.infile.read(16) 61 if not header : 62 break 62 63 (totalChunkSize, 63 64 chunkType, 64 65 numberOfItems, 65 66 reserved, 66 signature) = unpack( self.unpackHeader, header)67 except struct.error :68 raise pdlparser.PDLParserError, "This file doesn't seem to be valid ZjStream datas."69 self.infile.seek(totalChunkSize - len(header), 1)70 if chunkType == 2 :71 #self.logdebug("startPage")72 startpagecount += 173 elif chunkType == 3 :74 # self.logdebug("endPage")75 endpagecount += 176 #elif chunkType == 0 :77 # self.logdebug("startDoc")78 #elif chunkType == 1 :79 # self.logdebug("endDoc")80 81 #self.logdebug("Chunk size : %s" % totalChunkSize)82 #self.logdebug("Chunk type : 0x%08x" % chunkType)83 #self.logdebug("# items : %s" % numberOfItems)84 #self.logdebug("reserved : 0x%04x" % reserved)85 #self.logdebug("signature : 0x%04x" % signature)86 #self.logdebug("\n")67 signature) = unpack(unpackHeader, header) 68 self.infile.seek(totalChunkSize - len(header), 1) 69 if chunkType == 2 : 70 #self.logdebug("startPage") 71 startpagecount += 1 72 elif chunkType == 3 : 73 #self.logdebug("endPage") 74 endpagecount += 1 75 #elif chunkType == 0 : 76 # self.logdebug("startDoc") 77 #elif chunkType == 1 : 78 # self.logdebug("endDoc") 79 # 80 #self.logdebug("Chunk size : %s" % totalChunkSize) 81 #self.logdebug("Chunk type : 0x%08x" % chunkType) 82 #self.logdebug("# items : %s" % numberOfItems) 83 #self.logdebug("reserved : 0x%04x" % reserved) 84 #self.logdebug("signature : 0x%04x" % signature) 85 #self.logdebug("\n") 86 except struct.error : 87 raise pdlparser.PDLParserError, "This file doesn't seem to be valid ZjStream datas." 87 88 88 89 # Number of endpage commands should be sufficient,