Show
Ignore:
Timestamp:
06/20/07 21:22:27 (17 years ago)
Author:
jerome
Message:

Added the 'snmperrormask' directive.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/accounters/snmp.py

    r3180 r3190  
    9191                                  ]   
    9292                                   
    93 # TODO : make the following list configurable at runtime, possibly per printer.                                   
    94 errorConditions = [ 'No Paper', 
    95                     # 'No Toner', 
    96                     'Door Open', 
    97                     'Jammed', 
    98                     'Offline', 
    99                     'Service Requested', 
    100                     'Input Tray Missing', 
    101                     'Output Tray Missing', 
    102                     # 'Marker Supply Missing', 
    103                     'Output Full', 
    104                     'Input Tray Empty', 
    105                   ] 
     93# The default error mask to use when checking error conditions. 
     94defaultErrorMask = 0x4fcc # [ 'No Paper', 
     95                          #   'Door Open', 
     96                          #   'Jammed', 
     97                          #   'Offline', 
     98                          #   'Service Requested', 
     99                          #   'Input Tray Missing', 
     100                          #   'Output Tray Missing', 
     101                          #   'Output Full', 
     102                          #   'Input Tray Empty', 
     103                          # ] 
     104                           
    106105# WARNING : some printers don't support this one :                   
    107106prtConsoleDisplayBufferTextOID = "1.3.6.1.2.1.43.16.5.1.2.1.1" # SNMPv2-SMI::mib-2.43.16.5.1.2.1.1 
     
    147146            return True 
    148147        else : 
     148            try : 
     149                errormask = self.parent.filter.config.getPrinterSNMPErrorMask(self.parent.filter.PrinterName) 
     150            except AttributeError : # debug mode     
     151                errormask = defaultErrorMask 
     152            if errormask is None : 
     153                errormask = defaultErrorMask 
     154            errormaskbytes = [ chr((errormask & 0xff00) >> 8), 
     155                               chr((errormask & 0x00ff)), 
     156                             ] 
     157            errorConditions = self.extractErrorStates(errormaskbytes) 
     158            self.parent.filter.logdebug("Error conditions for mask 0x%04x : %s" \ 
     159                                               % (errormask, errorConditions)) 
    149160            for err in errorstates : 
    150161                if err in errorConditions : 
     162                    self.parent.filter.logdebug("Error condition '%s' encountered. PyKota will wait until this problem is fixed." % err) 
    151163                    return True 
     164            self.parent.filter.logdebug("No error condition matching mask 0x%04x" % errormask) 
    152165            return False     
    153166