- Timestamp:
- 02/09/04 14:07:06 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkhint
r1342 r1343 24 24 # 25 25 # $Log$ 26 # Revision 1.5 2004/02/09 13:07:06 jalet 27 # Should now be able to handle network + pjl printers 28 # 26 29 # Revision 1.4 2004/02/09 12:35:19 jalet 27 30 # De-uglyfication. … … 93 96 '/usr/bin/snmpwalk -v 1 -Cc -c public -Ov %(printer)s 2>/dev/null | grep Counter32 | tail -2 | head -1 | cut -d " " -f2', \ 94 97 ] 98 99 NETPJLTESTS = [ \ 100 '/usr/bin/pagecount.pl %(printer)s %(port)s 2>/dev/null', \ 101 '/bin/nc -w 2 %(printer)s %(port)s </usr/share/pykota/pagecount.pjl 2>/dev/null | /usr/bin/tail -2', \ 102 ] 95 103 96 104 class PKHint(PyKotaTool) : … … 166 174 return destination.split("/")[0] 167 175 168 def accepts(self, printer, commands) :176 def accepts(self, commands, printer, port=None) : 169 177 """Tries to get the printer's internal page counter via SNMP.""" 170 178 for command in commands : … … 185 193 devicestypes = self.extractDevices() # TODO : IT'S CUPS ONLY FOR NOW 186 194 configuration = [] 187 for (printer, device ) in printers.items() :195 for (printer, deviceuri) in printers.items() : 188 196 if self.matchString(printer, args) : 189 devicetype = self.searchDeviceType(devicestypes, device )190 device = self.extractDeviceFromURI(device )197 devicetype = self.searchDeviceType(devicestypes, deviceuri) 198 device = self.extractDeviceFromURI(deviceuri) 191 199 if devicetype is None : 192 200 sys.stderr.write("Unknown device %s for printer %s\n" % (device, printer)) … … 196 204 except ValueError : 197 205 hostname = device 198 snmpcommand = self.accepts(hostname, SNMPTESTS) 206 port = 9100 # TODO : may cause problems with other protocols. 207 208 snmpcommand = self.accepts(SNMPTESTS, hostname) 199 209 if snmpcommand is not None : 200 210 accounter = "querying" 201 211 requester = 'external(/usr/bin/waitprinter.sh %(printer)s && ' + snmpcommand + ')' 202 212 configuration.append((printer, accounter, requester)) 213 else : 214 netpjlcommand = self.accepts(NETPJLTESTS, hostname, port) 215 if netpjlcommand is not None : 216 accounter = "querying" 217 requester = 'external(' + netpjlcommand + ')' 218 configuration.append((printer, accounter, requester)) 203 219 elif devicetype == "direct" : 204 220 sys.stderr.write("Can't currently handle device %s for printer %s\n" % (device, printer))