Changeset 780 for pykota/trunk/pykota/requesters/external.py
- Timestamp:
- 02/10/03 01:42:17 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/requesters/external.py
r773 r780 15 15 # 16 16 # $Log$ 17 # Revision 1.3 2003/02/10 00:42:17 jalet 18 # External requester should be ok (untested) 19 # New syntax for configuration file wrt requesters 20 # 17 21 # Revision 1.2 2003/02/09 13:05:43 jalet 18 22 # Internationalization continues... … … 29 33 class Requester : 30 34 """A class to send queries to printers via external commands.""" 31 def __init__(self, config, printername ) :35 def __init__(self, config, printername, arguments) : 32 36 """Sets instance vars depending on the current printer.""" 33 37 self.printername = printername 34 raise PyKotaRequesterError, _("Requester not implemented yet.")38 self.commandline = arguments[0] 35 39 36 def getPrinterPageCounter(self, hostname) :37 """Returns the page counter from the hostname printer via SNMP.40 def getPrinterPageCounter(self, printer) : 41 """Returns the page counter from the printer via an external command. 38 42 39 Currently uses the snmpget external command. TODO : do it internally43 The external command must report the life time page number of the printer on stdout. 40 44 """ 41 raise PyKotaRequesterError, _("Requester not implemented yet.") 45 commandline = self.commandline % locals() 46 if printer is None : 47 raise PyKotaRequesterError, _("Unknown printer address in EXTERNAL(%s) for printer %s") % (commandline, self.printername) 48 answer = os.popen(commandline) 49 try : 50 pagecounter = int(answer.readline().strip()) 51 except IndexError : 52 raise PyKotaRequesterError, _("Unable to query printer %s via EXTERNAL(%s)") % (printer, commandline) 53 answer.close() 54 return pagecounter 42 55