Index: pykota/trunk/conf/pykota.conf.sample
===================================================================
--- pykota/trunk/conf/pykota.conf.sample (revision 3169)
+++ pykota/trunk/conf/pykota.conf.sample (revision 3180)
@@ -1274,4 +1274,33 @@
 
 
+# Defines the number of times the 'idle' printer status
+# has to be reported before it being considered stable.
+# Each check is done every 'statusstabilizationdelay' seconds
+# as defined below.
+#
+# This directive can be set either globally or on a per printer
+# basis. 
+#
+# When not set, an hardcoded value of 5 times is used.
+# The value must be a strictly positive integer.
+statusstabilizationloops = 5
+
+
+
+# Defines the number of seconds to wait between two consecutive
+# checks of the printer's status when using hardware accounting.
+#
+# Each check is done up to 'statusstabilizationloops' times.
+#
+# This directive can be set either globally or on a per printer
+# basis. 
+#
+# When not set, an hardcoded value of 4.0 seconds is used.
+# The value must be a positive floating point value greater
+# than or equal to 0.25 seconds.
+statusstabilizationdelay = 4.0
+
+
+
 # Defines a set of coefficients for ink accounting.
 #
Index: pykota/trunk/pykota/config.py
===================================================================
--- pykota/trunk/pykota/config.py (revision 3172)
+++ pykota/trunk/pykota/config.py (revision 3180)
@@ -597,4 +597,36 @@
                 return maxdelay
         
+    def getStatusStabilizationLoops(self, printername) :    
+        """Returns the number of times the printer must return the 'idle' status to consider it stable."""
+        try : 
+            stab = self.getPrinterOption(printername, "statusstabilizationloops")
+        except PyKotaConfigError :    
+            return None         # tells to use hardcoded value
+        else :    
+            try :
+                stab = int(stab)
+                if stab < 1 :
+                    raise ValueError
+            except (TypeError, ValueError) :
+                raise PyKotaConfigError, _("Incorrect value %s for the statusstabilizationloops directive in section %s") % (str(stab), printername)
+            else :    
+                return stab
+        
+    def getStatusStabilizationDelay(self, printername) :    
+        """Returns the number of seconds to wait between two checks of the printer's status."""
+        try : 
+            stab = self.getPrinterOption(printername, "statusstabilizationdelay")
+        except PyKotaConfigError :    
+            return None         # tells to use hardcoded value
+        else :    
+            try :
+                stab = float(stab)
+                if stab < 0.25 :
+                    raise ValueError
+            except (TypeError, ValueError) :
+                raise PyKotaConfigError, _("Incorrect value %s for the statusstabilizationdelay directive in section %s") % (str(stab), printername)
+            else :    
+                return stab
+        
     def getWinbindSeparator(self) :          
         """Returns the winbind separator's value if it is set, else None."""
Index: pykota/trunk/pykota/constants.py
===================================================================
--- pykota/trunk/pykota/constants.py (revision 3175)
+++ pykota/trunk/pykota/constants.py (revision 3180)
@@ -24,5 +24,17 @@
 """This module contains the definitions of constants used by PyKota."""
 
-ITERATIONDELAY = 4      # time to sleep between two loops
-STABILIZATIONDELAY = 5  # number of consecutive times the idle status must be seen before we consider it to be stable
+STATUSSTABILIZATIONDELAY = 4.0 # time to sleep between two loops
+STATUSSTABILIZATIONLOOPS = 5  # number of consecutive times the 'idle' status must be seen before we consider it to be stable
 NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default.
+
+def get(application, varname) :
+    """Retrieves the value of a particular printer variable from configuration file, else a constant defined here."""
+    pname = application.PrinterName
+    try :
+        value = getattr(application.config, "get%(varname)s" % locals())(pname)
+        if value is None :
+            raise TypeError     # Use hardcoded value
+    except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy !
+        value = globals().get(varname.upper())
+        application.logdebug("No value defined for %(varname)s for printer %(pname)s, using %(value)s." % locals())
+    return value    
Index: pykota/trunk/pykota/accounters/snmp.py
===================================================================
--- pykota/trunk/pykota/accounters/snmp.py (revision 3175)
+++ pykota/trunk/pykota/accounters/snmp.py (revision 3180)
@@ -154,9 +154,6 @@
     def waitPrinting(self) :
         """Waits for printer status being 'printing'."""
-        try :
-            noprintingmaxdelay = int(self.parent.filter.config.getNoPrintingMaxDelay(self.parent.filter.PrinterName))
-        except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy !
-            noprintingmaxdelay = constants.NOPRINTINGMAXDELAY
-            self.parent.filter.logdebug("No max delay defined for printer %s, using %i seconds." % (self.parent.filter.PrinterName, noprintingmaxdelay))
+        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
+        noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay")
         if not noprintingmaxdelay :
             self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName)
@@ -203,8 +200,10 @@
                             break
             self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)    
-            time.sleep(constants.ITERATIONDELAY)
+            time.sleep(statusstabilizationdelay)
         
     def waitIdle(self) :
         """Waits for printer status being 'idle'."""
+        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
+        statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops")
         idle_num = idle_flag = 0
         while 1 :
@@ -225,5 +224,5 @@
                     return 
                 idle_num += 1
-                if idle_num >= constants.STABILIZATIONDELAY :
+                if idle_num >= statusstabilizationloops :
                     # printer status is stable, we can exit
                     break
@@ -231,5 +230,5 @@
                 idle_num = 0
             self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName)    
-            time.sleep(constants.ITERATIONDELAY)
+            time.sleep(statusstabilizationdelay)
             
     def retrieveInternalPageCounter(self) :
Index: pykota/trunk/pykota/accounters/pjl.py
===================================================================
--- pykota/trunk/pykota/accounters/pjl.py (revision 3177)
+++ pykota/trunk/pykota/accounters/pjl.py (revision 3180)
@@ -169,9 +169,6 @@
     def waitPrinting(self) :
         """Waits for printer status being 'printing'."""
-        try :
-            noprintingmaxdelay = int(self.parent.filter.config.getNoPrintingMaxDelay(self.parent.filter.PrinterName))
-        except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy !
-            noprintingmaxdelay = constants.NOPRINTINGMAXDELAY
-            self.parent.filter.logdebug("No max delay defined for printer %s, using %i seconds." % (self.parent.filter.PrinterName, noprintingmaxdelay))
+        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
+        noprintingmaxdelay = constants.get(self.parent.filter, "NoPrintingMaxDelay")
         if not noprintingmaxdelay :
             self.parent.filter.logdebug("Will wait indefinitely until printer %s is in 'printing' state." % self.parent.filter.PrinterName)
@@ -212,8 +209,10 @@
                             break
             self.parent.filter.logdebug(_("Waiting for printer %s to be printing...") % self.parent.filter.PrinterName)
-            time.sleep(constants.ITERATIONDELAY)
+            time.sleep(statusstabilizationdelay)
         
     def waitIdle(self) :
         """Waits for printer status being 'idle'."""
+        statusstabilizationdelay = constants.get(self.parent.filter, "StatusStabilizationDelay")
+        statusstabilizationloops = constants.get(self.parent.filter, "StatusStabilizationLoops")
         idle_num = 0
         while True :
@@ -226,5 +225,5 @@
                     return 
                 idle_num += 1
-                if idle_num >= constants.STABILIZATIONDELAY :
+                if idle_num >= statusstabilizationloops :
                     # printer status is stable, we can exit
                     break
@@ -232,5 +231,5 @@
                 idle_num = 0
             self.parent.filter.logdebug(_("Waiting for printer %s's idle status to stabilize...") % self.parent.filter.PrinterName)
-            time.sleep(constants.ITERATIONDELAY)
+            time.sleep(statusstabilizationdelay)
     
     def retrieveInternalPageCounter(self) :
