Changeset 3530 for pykota/trunk
- Timestamp:
- 04/16/10 15:49:27 (15 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/snmp.py
r3529 r3530 157 157 """Waits for printer status being 'printing'.""" 158 158 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 159 increment = 1 159 160 noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay") 160 161 if not noprintingmaxdelay : … … 166 167 while True : 167 168 self.retrieveSNMPValues() 169 waitdelay = statusstabilizationdelay * increment 170 error = self.checkIfError(self.printerDetectedErrorState) 168 171 pstatusAsString = printerStatusValues.get(self.printerStatus) 172 dstatusAsString = deviceStatusValues.get(self.deviceStatus) 169 173 if pstatusAsString in ('printing', 'warmup') : 170 174 break … … 184 188 elif noprintingmaxdelay \ 185 189 and ((time.time() - self.timebefore) > noprintingmaxdelay) \ 186 and not self.checkIfError(self.printerDetectedErrorState):190 and not error : 187 191 # More than X seconds without the printer being in 'printing' mode 188 192 # We can safely assume this won't change if printer is now 'idle' 189 dstatusAsString = deviceStatusValues.get(self.deviceStatus)190 193 if (pstatusAsString == 'idle') or \ 191 194 ((pstatusAsString == 'other') and \ … … 200 203 self.parent.filter.printInfo("Printer %s has probably already printed this job !!!" % self.parent.filter.PrinterName, "warn") 201 204 break 202 self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) 203 time.sleep(statusstabilizationdelay) 205 if error or (dstatusAsString == "down") : 206 if waitdelay < constants.FIVEMINUTES : 207 increment *= 2 208 self.parent.filter.logdebug("Waiting %s seconds for printer %s to be printing..." % (waitdelay, self.parent.filter.PrinterName)) 209 time.sleep(waitdelay) 204 210 205 211 def waitIdle(self) : … … 207 213 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 208 214 statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops") 209 idle_num = idle_flag = 0 215 increment = 1 216 idle_num = 0 210 217 while True : 211 218 self.retrieveSNMPValues() 219 waitdelay = statusstabilizationdelay * increment 220 error = self.checkIfError(self.printerDetectedErrorState) 212 221 pstatusAsString = printerStatusValues.get(self.printerStatus) 213 222 dstatusAsString = deviceStatusValues.get(self.deviceStatus) 214 idle_flag = 0215 if (not self.checkIfError(self.printerDetectedErrorState))\216 and ((pstatusAsString == 'idle') or\217 ((pstatusAsString == 'other') and \218 (dstatusAsString == 'running'))) :219 i dle_flag = 1 # Standby / Powersave is considered idle223 idle_flag = False 224 if (not error) and ((pstatusAsString == 'idle') or \ 225 ((pstatusAsString == 'other') and \ 226 (dstatusAsString == 'running'))) : 227 idle_flag = True # Standby / Powersave is considered idle 228 increment = 1 # Reset initial stabilization delay 220 229 if idle_flag : 221 230 if (self.printerInternalPageCounter is not None) \ … … 230 239 else : 231 240 idle_num = 0 232 self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName) 233 time.sleep(statusstabilizationdelay) 241 if error or (dstatusAsString == "down") : 242 if waitdelay < constants.FIVEMINUTES : 243 increment *= 2 244 self.parent.filter.logdebug("Waiting %s seconds for printer %s's idle status to stabilize..." % (waitdelay, 245 self.parent.filter.PrinterName)) 246 time.sleep(waitdelay) 234 247 235 248 def retrieveInternalPageCounter(self) : … … 243 256 self.waitIdle() 244 257 except : 245 self.parent.filter.printInfo( _("SNMP querying stage interrupted. Using latest value seen for internal page counter (%s) on printer %s.")% (self.printerInternalPageCounter, self.parent.filter.PrinterName), "warn")258 self.parent.filter.printInfo("SNMP querying stage interrupted. Using latest value seen for internal page counter (%s) on printer %s." % (self.printerInternalPageCounter, self.parent.filter.PrinterName), "warn") 246 259 raise 247 260 return self.printerInternalPageCounter … … 333 346 sys.stderr.write("Usage : python %s printer_ip_address\n" % sys.argv[0]) 334 347 else : 335 def _(msg) :336 return msg337 338 348 pagecounter = main(sys.argv[1]) 339 349 print "Internal page counter's value is : %s" % pagecounter -
pykota/trunk/pykota/constants.py
r3489 r3530 25 25 STATUSSTABILIZATIONLOOPS = 5 # number of consecutive times the 'idle' status must be seen before we consider it to be stable 26 26 NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default. 27 FIVEMINUTES = 300 # Five minutes : maximum delay between two SNMP queries 27 28 28 29 def get(application, varname) :