Changeset 3180 for pykota/trunk
- Timestamp:
- 05/29/07 23:03:12 (17 years ago)
- Location:
- pykota/trunk
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/conf/pykota.conf.sample
r3169 r3180 1274 1274 1275 1275 1276 # Defines the number of times the 'idle' printer status 1277 # has to be reported before it being considered stable. 1278 # Each check is done every 'statusstabilizationdelay' seconds 1279 # as defined below. 1280 # 1281 # This directive can be set either globally or on a per printer 1282 # basis. 1283 # 1284 # When not set, an hardcoded value of 5 times is used. 1285 # The value must be a strictly positive integer. 1286 statusstabilizationloops = 5 1287 1288 1289 1290 # Defines the number of seconds to wait between two consecutive 1291 # checks of the printer's status when using hardware accounting. 1292 # 1293 # Each check is done up to 'statusstabilizationloops' times. 1294 # 1295 # This directive can be set either globally or on a per printer 1296 # basis. 1297 # 1298 # When not set, an hardcoded value of 4.0 seconds is used. 1299 # The value must be a positive floating point value greater 1300 # than or equal to 0.25 seconds. 1301 statusstabilizationdelay = 4.0 1302 1303 1304 1276 1305 # Defines a set of coefficients for ink accounting. 1277 1306 # -
pykota/trunk/pykota/accounters/pjl.py
r3177 r3180 169 169 def waitPrinting(self) : 170 170 """Waits for printer status being 'printing'.""" 171 try : 172 noprintingmaxdelay = int(self.parent.filter.config.getNoPrintingMaxDelay(self.parent.filter.PrinterName)) 173 except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy ! 174 noprintingmaxdelay = constants.NOPRINTINGMAXDELAY 175 self.parent.filter.logdebug("No max delay defined for printer %s, using %i seconds." % (self.parent.filter.PrinterName, noprintingmaxdelay)) 171 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 172 noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay") 176 173 if not noprintingmaxdelay : 177 174 self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName) … … 212 209 break 213 210 self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) 214 time.sleep( constants.ITERATIONDELAY)211 time.sleep(statusstabilizationdelay) 215 212 216 213 def waitIdle(self) : 217 214 """Waits for printer status being 'idle'.""" 215 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 216 statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops") 218 217 idle_num = 0 219 218 while True : … … 226 225 return 227 226 idle_num += 1 228 if idle_num >= constants.STABILIZATIONDELAY:227 if idle_num >= statusstabilizationloops : 229 228 # printer status is stable, we can exit 230 229 break … … 232 231 idle_num = 0 233 232 self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName) 234 time.sleep( constants.ITERATIONDELAY)233 time.sleep(statusstabilizationdelay) 235 234 236 235 def retrieveInternalPageCounter(self) : -
pykota/trunk/pykota/accounters/snmp.py
r3175 r3180 154 154 def waitPrinting(self) : 155 155 """Waits for printer status being 'printing'.""" 156 try : 157 noprintingmaxdelay = int(self.parent.filter.config.getNoPrintingMaxDelay(self.parent.filter.PrinterName)) 158 except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy ! 159 noprintingmaxdelay = constants.NOPRINTINGMAXDELAY 160 self.parent.filter.logdebug("No max delay defined for printer %s, using %i seconds." % (self.parent.filter.PrinterName, noprintingmaxdelay)) 156 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 157 noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay") 161 158 if not noprintingmaxdelay : 162 159 self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName) … … 203 200 break 204 201 self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName) 205 time.sleep( constants.ITERATIONDELAY)202 time.sleep(statusstabilizationdelay) 206 203 207 204 def waitIdle(self) : 208 205 """Waits for printer status being 'idle'.""" 206 statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay") 207 statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops") 209 208 idle_num = idle_flag = 0 210 209 while 1 : … … 225 224 return 226 225 idle_num += 1 227 if idle_num >= constants.STABILIZATIONDELAY:226 if idle_num >= statusstabilizationloops : 228 227 # printer status is stable, we can exit 229 228 break … … 231 230 idle_num = 0 232 231 self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName) 233 time.sleep( constants.ITERATIONDELAY)232 time.sleep(statusstabilizationdelay) 234 233 235 234 def retrieveInternalPageCounter(self) : -
pykota/trunk/pykota/config.py
r3172 r3180 597 597 return maxdelay 598 598 599 def getStatusStabilizationLoops(self, printername) : 600 """Returns the number of times the printer must return the 'idle' status to consider it stable.""" 601 try : 602 stab = self.getPrinterOption(printername, "statusstabilizationloops") 603 except PyKotaConfigError : 604 return None # tells to use hardcoded value 605 else : 606 try : 607 stab = int(stab) 608 if stab < 1 : 609 raise ValueError 610 except (TypeError, ValueError) : 611 raise PyKotaConfigError, _("Incorrect value %s for the statusstabilizationloops directive in section %s") % (str(stab), printername) 612 else : 613 return stab 614 615 def getStatusStabilizationDelay(self, printername) : 616 """Returns the number of seconds to wait between two checks of the printer's status.""" 617 try : 618 stab = self.getPrinterOption(printername, "statusstabilizationdelay") 619 except PyKotaConfigError : 620 return None # tells to use hardcoded value 621 else : 622 try : 623 stab = float(stab) 624 if stab < 0.25 : 625 raise ValueError 626 except (TypeError, ValueError) : 627 raise PyKotaConfigError, _("Incorrect value %s for the statusstabilizationdelay directive in section %s") % (str(stab), printername) 628 else : 629 return stab 630 599 631 def getWinbindSeparator(self) : 600 632 """Returns the winbind separator's value if it is set, else None.""" -
pykota/trunk/pykota/constants.py
r3175 r3180 24 24 """This module contains the definitions of constants used by PyKota.""" 25 25 26 ITERATIONDELAY = 4# time to sleep between two loops27 STA BILIZATIONDELAY = 5 # number of consecutive times the idlestatus must be seen before we consider it to be stable26 STATUSSTABILIZATIONDELAY = 4.0 # time to sleep between two loops 27 STATUSSTABILIZATIONLOOPS = 5 # number of consecutive times the 'idle' status must be seen before we consider it to be stable 28 28 NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default. 29 30 def get(application, varname) : 31 """Retrieves the value of a particular printer variable from configuration file, else a constant defined here.""" 32 pname = application.PrinterName 33 try : 34 value = getattr(application.config, "get%(varname)s" % locals())(pname) 35 if value is None : 36 raise TypeError # Use hardcoded value 37 except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy ! 38 value = globals().get(varname.upper()) 39 application.logdebug("No value defined for %(varname)s for printer %(pname)s, using %(value)s." % locals()) 40 return value