Index: /pykota/trunk/conf/pykota.conf.sample
===================================================================
--- /pykota/trunk/conf/pykota.conf.sample (revision 3180)
+++ /pykota/trunk/conf/pykota.conf.sample (revision 3190)
@@ -1284,5 +1284,5 @@
 # When not set, an hardcoded value of 5 times is used.
 # The value must be a strictly positive integer.
-statusstabilizationloops = 5
+statusstabilizationloops : 5
 
 
@@ -1299,5 +1299,47 @@
 # The value must be a positive floating point value greater
 # than or equal to 0.25 seconds.
-statusstabilizationdelay = 4.0
+statusstabilizationdelay : 4.0
+
+
+
+# Defines a bit mask to specify the set of error conditions
+# reported through SNMP for which PyKota has to wait indefinitely
+# until such an error is fixed before continuing with printing
+# and/or accounting.
+#
+# This directive can be set either globally or on a per printer
+# basis. 
+#
+# The bit values are specified as in RFC3805 (Printer MIB v2),
+# as an ORed value of one or more of the following conditions :
+#
+#       1000 0000 0000 0000 : Low Paper
+#       0100 0000 0000 0000 : No Paper
+#       0010 0000 0000 0000 : Low Toner
+#       0001 0000 0000 0000 : No Toner
+#       0000 1000 0000 0000 : Door Open
+#       0000 0100 0000 0000 : Jammed
+#       0000 0010 0000 0000 : Offline
+#       0000 0001 0000 0000 : Service Requested
+#       0000 0000 1000 0000 : Input Tray Missing
+#       0000 0000 0100 0000 : Output Tray Missing
+#       0000 0000 0010 0000 : Marker Supply Missing
+#       0000 0000 0001 0000 : Output Near Full
+#       0000 0000 0000 1000 : Output Full
+#       0000 0000 0000 0100 : Input Tray Empty
+#       0000 0000 0000 0010 : Overdue Preventive Maintainance
+#       0000 0000 0000 0001 : Not assigned
+#
+# When not set, an hardcoded value of hexadecimal 0x4FCC is used,
+# which means that PyKota will wait indefinitely when using SNMP
+# hardware accounting if one of the following conditions is met :
+#
+#   No Paper, Door Open, Jammed, Offline, Service Requested,
+#   Input Tray Missing, Output Tray Missing, Output Full, Input Tray Empty
+# 
+# This value can be specified either in hexadecimal (prefixed with 0x),
+# in octal (prefixed with 0) or in decimal (no prefix).
+#
+snmperrormask : 0x4FCC
 
 
Index: /pykota/trunk/pykota/config.py
===================================================================
--- /pykota/trunk/pykota/config.py (revision 3184)
+++ /pykota/trunk/pykota/config.py (revision 3190)
@@ -631,4 +631,25 @@
                 return stab
         
+    def getPrinterSNMPErrorMask(self, printername) :    
+        """Returns the SNMP error mask for a particular printer, or None if not defined."""
+        try : 
+            errmask = self.getPrinterOption(printername, "snmperrormask").lower()
+        except PyKotaConfigError :    
+            return None         # tells to use hardcoded value
+        else :    
+            try :
+                if errmask.startswith("0x") :
+                    value = int(errmask, 16)
+                elif errmask.startswith("0") :    
+                    value = int(errmask, 8)
+                else :    
+                    value = int(errmask)
+                if 0 <= value < 65536 :
+                    return value
+                else :    
+                    raise ValueError
+            except ValueError :    
+                raise PyKotaConfigError, _("Incorrect value %s for the snmperrormask directive in section %s") % (errmask, printername)
+        
     def getWinbindSeparator(self) :          
         """Returns the winbind separator's value if it is set, else None."""
Index: /pykota/trunk/pykota/accounters/snmp.py
===================================================================
--- /pykota/trunk/pykota/accounters/snmp.py (revision 3180)
+++ /pykota/trunk/pykota/accounters/snmp.py (revision 3190)
@@ -91,17 +91,16 @@
                                   ]  
                                   
-# TODO : make the following list configurable at runtime, possibly per printer.                                  
-errorConditions = [ 'No Paper',
-                    # 'No Toner',
-                    'Door Open',
-                    'Jammed',
-                    'Offline',
-                    'Service Requested',
-                    'Input Tray Missing',
-                    'Output Tray Missing',
-                    # 'Marker Supply Missing',
-                    'Output Full',
-                    'Input Tray Empty',
-                  ]
+# The default error mask to use when checking error conditions.
+defaultErrorMask = 0x4fcc # [ 'No Paper',
+                          #   'Door Open',
+                          #   'Jammed',
+                          #   'Offline',
+                          #   'Service Requested',
+                          #   'Input Tray Missing',
+                          #   'Output Tray Missing',
+                          #   'Output Full',
+                          #   'Input Tray Empty',
+                          # ]
+                          
 # WARNING : some printers don't support this one :                  
 prtConsoleDisplayBufferTextOID = "1.3.6.1.2.1.43.16.5.1.2.1.1" # SNMPv2-SMI::mib-2.43.16.5.1.2.1.1
@@ -147,7 +146,21 @@
             return True
         else :
+            try :
+                errormask = self.parent.filter.config.getPrinterSNMPErrorMask(self.parent.filter.PrinterName)
+            except AttributeError : # debug mode    
+                errormask = defaultErrorMask
+            if errormask is None :
+                errormask = defaultErrorMask
+            errormaskbytes = [ chr((errormask & 0xff00) >> 8),
+                               chr((errormask & 0x00ff)),
+                             ]
+            errorConditions = self.extractErrorStates(errormaskbytes)
+            self.parent.filter.logdebug("Error conditions for mask 0x%04x : %s" \
+                                               % (errormask, errorConditions))
             for err in errorstates :
                 if err in errorConditions :
+                    self.parent.filter.logdebug("Error condition '%s' encountered. PyKota will wait until this problem is fixed." % err)
                     return True
+            self.parent.filter.logdebug("No error condition matching mask 0x%04x" % errormask)
             return False    
         
