Changeset 2423

Show
Ignore:
Timestamp:
09/05/05 13:16:56 (19 years ago)
Author:
jerome
Message:

Prepare for parametrized internal hardware accounters

Location:
pykota/trunk/pykota/accounters
Files:
2 modified

Legend:

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

    r2409 r2423  
    6060        self.parent = parent 
    6161        self.printerHostname = printerhostname 
     62        self.port = 9100 
    6263        self.printerInternalPageCounter = self.printerStatus = None 
    6364        self.timedout = 0 
     
    7071    def retrievePJLValues(self) :     
    7172        """Retrieves a printer's internal page counter and status via PJL.""" 
    72         port = 9100 
    7373        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
    7474        try : 
    75             sock.connect((self.printerHostname, port)) 
     75            sock.connect((self.printerHostname, self.port)) 
    7676        except socket.error, msg : 
    77             self.parent.filter.printInfo(_("Problem during connection to %s:%s : %s") % (self.printerHostname, port, msg), "warn") 
     77            self.parent.filter.printInfo(_("Problem during connection to %s:%s : %s") % (self.printerHostname, self.port, msg), "warn") 
    7878        else : 
    7979            self.parent.filter.logdebug("Connected to printer %s" % self.printerHostname) 
     
    8181                sock.send(pjlMessage) 
    8282            except socket.error, msg : 
    83                 self.parent.filter.printInfo(_("Problem while sending PJL query to %s:%s : %s") % (self.printerHostname, port, msg), "warn") 
     83                self.parent.filter.printInfo(_("Problem while sending PJL query to %s:%s : %s") % (self.printerHostname, self.port, msg), "warn") 
    8484            else :     
    8585                self.parent.filter.logdebug("Query sent to %s : %s" % (self.printerHostname, repr(pjlMessage))) 
     
    9595                        break   # our alarm handler was launched, probably 
    9696                    except socket.error :     
    97                         self.parent.filter.printInfo(_("Problem while receiving PJL answer from %s:%s : %s") % (self.printerHostname, port, msg), "warn") 
     97                        self.parent.filter.printInfo(_("Problem while receiving PJL answer from %s:%s : %s") % (self.printerHostname, self.port, msg), "warn") 
    9898                    else :     
    9999                        readnext = 0 
  • pykota/trunk/pykota/accounters/snmp.py

    r2409 r2423  
    6868            self.parent = parent 
    6969            self.printerHostname = printerhostname 
     70            self.community = "public" 
     71            self.port = 161 
    7072            self.printerInternalPageCounter = None 
    7173            self.printerStatus = None 
     
    7678            ver = alpha.protoVersions[alpha.protoVersionId1] 
    7779            req = ver.Message() 
    78             req.apiAlphaSetCommunity('public') 
     80            req.apiAlphaSetCommunity(self.community) 
    7981            req.apiAlphaSetPdu(ver.GetRequestPdu()) 
    8082            req.apiAlphaGetPdu().apiAlphaSetVarBindList((pageCounterOID, ver.Null()), \ 
     
    8385            tsp = Manager() 
    8486            try : 
    85                 tsp.sendAndReceive(req.berEncode(), (self.printerHostname, 161), (self.handleAnswer, req)) 
     87                tsp.sendAndReceive(req.berEncode(), \ 
     88                                   (self.printerHostname, self.port), \ 
     89                                   (self.handleAnswer, req)) 
    8690            except (SnmpOverUdpError, select.error), msg :     
    8791                self.parent.filter.printInfo(_("Network error while doing SNMP queries on printer %s : %s") % (self.printerHostname, msg), "warn")