Changeset 2615
- Timestamp:
- 01/13/06 21:33:33 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/NEWS
r2614 r2615 24 24 - 1.24alpha6 : 25 25 26 - Fixed internal SNMP and PJL handling code for very fast 27 printers : PyKota didn't see them going from 'idle' 28 to 'printing' to 'idle' again. 29 26 30 - Now waitprinter.sh accepts SNMP version number and 27 31 community name as arguments, thanks to Brandon -
pykota/trunk/pykota/accounters/pjl.py
r2584 r2615 33 33 ITERATIONDELAY = 1 # 1 Second 34 34 STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 35 NOPRINTINGMAXDELAY = 30 # The printer must begin to print within 30 seconds. 35 36 36 37 # Here's the real thing : … … 130 131 def waitPrinting(self) : 131 132 """Waits for printer status being 'printing'.""" 133 previousValue = self.parent.getLastPageCounter() 134 timebefore = time.time() 132 135 firstvalue = None 133 136 while 1: … … 147 150 # So we can probably quit being sure it is printing. 148 151 self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn") 152 break 153 elif (time.time() - timebefore) > NOPRINTINGMAXDELAY : 154 # More than X seconds without the printer being in 'printing' mode 155 # We can safely assume this won't change 156 if self.printerInternalPageCounter == previousValue : 157 # Here the job won't be printed, because probably 158 # the printer rejected it for some reason. 159 self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn") 160 else : 161 # Here the job has already been entirely printed, and 162 # the printer has already passed from 'idle' to 'printing' to 'idle' again. 163 self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 149 164 break 150 165 self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) … … 204 219 self.filter = fakeFilter() 205 220 self.protocolHandler = Handler(self, sys.argv[1]) 221 222 def getLastPageCounter(self) : 223 return 0 206 224 207 225 acc = fakeAccounter() -
pykota/trunk/pykota/accounters/snmp.py
r2584 r2615 25 25 ITERATIONDELAY = 1.5 # 1.5 Second 26 26 STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 27 NOPRINTINGMAXDELAY = 30 # The printer must begin to print within 30 seconds. 27 28 28 29 import sys … … 97 98 def handleAnswer(self, wholeMsg, notusedhere, req): 98 99 """Decodes and handles the SNMP answer.""" 99 self.parent.filter.logdebug("SNMP message: '%s'" % repr(wholeMsg))100 self.parent.filter.logdebug("SNMP answer : '%s'" % repr(wholeMsg)) 100 101 ver = alpha.protoVersions[alpha.protoVersionId1] 101 102 rsp = ver.Message() … … 118 119 self.printerStatus = self.values[1] 119 120 self.deviceStatus = self.values[2] 120 self.parent.filter.logdebug("SNMP answer is decoded : PageCounter : %s PrinterStatus : %s DeviceStatus : %s" % tuple(self.values)) 121 self.parent.filter.logdebug("SNMP answer decoded : PageCounter : %s PrinterStatus : '%s' DeviceStatus : '%s'" \ 122 % (self.printerInternalPageCounter, \ 123 printerStatusValues.get(self.printerStatus, "ILLEGAL VALUE"), \ 124 deviceStatusValues.get(self.deviceStatus, "ILLEGAL VALUE"))) 121 125 except IndexError : 122 126 self.parent.filter.logdebug("SNMP answer is incomplete : %s" % str(self.values)) … … 127 131 def waitPrinting(self) : 128 132 """Waits for printer status being 'printing'.""" 133 previousValue = self.parent.getLastPageCounter() 134 timebefore = time.time() 129 135 firstvalue = None 130 136 while 1: … … 145 151 # So we can probably quit being sure it is printing. 146 152 self.parent.filter.printInfo("Printer %s is lying to us !!!" % self.parent.filter.PrinterName, "warn") 153 break 154 elif (time.time() - timebefore) > NOPRINTINGMAXDELAY : 155 # More than X seconds without the printer being in 'printing' mode 156 # We can safely assume this won't change 157 if self.printerInternalPageCounter == previousValue : 158 # Here the job won't be printed, because probably 159 # the printer rejected it for some reason. 160 self.parent.filter.printInfo("Printer %s probably won't print this job !!!" % self.parent.filter.PrinterName, "warn") 161 else : 162 # Here the job has already been entirely printed, and 163 # the printer has already passed from 'idle' to 'printing' to 'idle' again. 164 self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 147 165 break 148 166 self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) … … 206 224 self.filter = fakeFilter() 207 225 self.protocolHandler = Handler(self, hostname) 226 227 def getLastPageCounter(self) : 228 return 0 208 229 209 230 acc = fakeAccounter()