Changeset 3190 for pykota/trunk
- Timestamp:
- 06/20/07 21:22:27 (17 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/conf/pykota.conf.sample
r3180 r3190 1284 1284 # When not set, an hardcoded value of 5 times is used. 1285 1285 # The value must be a strictly positive integer. 1286 statusstabilizationloops =51286 statusstabilizationloops : 5 1287 1287 1288 1288 … … 1299 1299 # The value must be a positive floating point value greater 1300 1300 # than or equal to 0.25 seconds. 1301 statusstabilizationdelay = 4.0 1301 statusstabilizationdelay : 4.0 1302 1303 1304 1305 # Defines a bit mask to specify the set of error conditions 1306 # reported through SNMP for which PyKota has to wait indefinitely 1307 # until such an error is fixed before continuing with printing 1308 # and/or accounting. 1309 # 1310 # This directive can be set either globally or on a per printer 1311 # basis. 1312 # 1313 # The bit values are specified as in RFC3805 (Printer MIB v2), 1314 # as an ORed value of one or more of the following conditions : 1315 # 1316 # 1000 0000 0000 0000 : Low Paper 1317 # 0100 0000 0000 0000 : No Paper 1318 # 0010 0000 0000 0000 : Low Toner 1319 # 0001 0000 0000 0000 : No Toner 1320 # 0000 1000 0000 0000 : Door Open 1321 # 0000 0100 0000 0000 : Jammed 1322 # 0000 0010 0000 0000 : Offline 1323 # 0000 0001 0000 0000 : Service Requested 1324 # 0000 0000 1000 0000 : Input Tray Missing 1325 # 0000 0000 0100 0000 : Output Tray Missing 1326 # 0000 0000 0010 0000 : Marker Supply Missing 1327 # 0000 0000 0001 0000 : Output Near Full 1328 # 0000 0000 0000 1000 : Output Full 1329 # 0000 0000 0000 0100 : Input Tray Empty 1330 # 0000 0000 0000 0010 : Overdue Preventive Maintainance 1331 # 0000 0000 0000 0001 : Not assigned 1332 # 1333 # When not set, an hardcoded value of hexadecimal 0x4FCC is used, 1334 # which means that PyKota will wait indefinitely when using SNMP 1335 # hardware accounting if one of the following conditions is met : 1336 # 1337 # No Paper, Door Open, Jammed, Offline, Service Requested, 1338 # Input Tray Missing, Output Tray Missing, Output Full, Input Tray Empty 1339 # 1340 # This value can be specified either in hexadecimal (prefixed with 0x), 1341 # in octal (prefixed with 0) or in decimal (no prefix). 1342 # 1343 snmperrormask : 0x4FCC 1302 1344 1303 1345 -
pykota/trunk/pykota/accounters/snmp.py
r3180 r3190 91 91 ] 92 92 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. 94 defaultErrorMask = 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 106 105 # WARNING : some printers don't support this one : 107 106 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 146 return True 148 147 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)) 149 160 for err in errorstates : 150 161 if err in errorConditions : 162 self.parent.filter.logdebug("Error condition '%s' encountered. PyKota will wait until this problem is fixed." % err) 151 163 return True 164 self.parent.filter.logdebug("No error condition matching mask 0x%04x" % errormask) 152 165 return False 153 166 -
pykota/trunk/pykota/config.py
r3184 r3190 631 631 return stab 632 632 633 def getPrinterSNMPErrorMask(self, printername) : 634 """Returns the SNMP error mask for a particular printer, or None if not defined.""" 635 try : 636 errmask = self.getPrinterOption(printername, "snmperrormask").lower() 637 except PyKotaConfigError : 638 return None # tells to use hardcoded value 639 else : 640 try : 641 if errmask.startswith("0x") : 642 value = int(errmask, 16) 643 elif errmask.startswith("0") : 644 value = int(errmask, 8) 645 else : 646 value = int(errmask) 647 if 0 <= value < 65536 : 648 return value 649 else : 650 raise ValueError 651 except ValueError : 652 raise PyKotaConfigError, _("Incorrect value %s for the snmperrormask directive in section %s") % (errmask, printername) 653 633 654 def getWinbindSeparator(self) : 634 655 """Returns the winbind separator's value if it is set, else None."""