Changeset 2217 for pykota/trunk/bin/cupspykota
- Timestamp:
- 04/24/05 00:01:46 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2210 r2217 148 148 return dirvalues 149 149 150 def getJob OriginatingHostnameFromPageLog(self, cupsconfig, printername, username, jobid) :151 """Retrieves the job-originating-hostname from the CUPS page_log file if possible."""150 def getJobInfosFromPageLog(self, cupsconfig, printername, username, jobid) : 151 """Retrieves the job-originating-hostname and job-billing attributes from the CUPS page_log file if possible.""" 152 152 pagelogpath = cupsconfig.get("pagelog", "/var/log/cups/page_log") 153 153 self.logdebug("Trying to extract job-originating-host-name from %s" % pagelogpath) … … 156 156 except IOError : 157 157 self.logdebug("Unable to open %s" % pagelogpath) 158 return # no page log or can't read it, originating hostname unknown yet158 return (None, None) # no page log or can't read it, originating hostname unknown yet 159 159 else : 160 160 # TODO : read backward so we could take first value seen … … 173 173 if matchingline is None : 174 174 self.logdebug("No matching line found in %s" % pagelogpath) 175 return # correct line not found, job-originating-host-name unknown175 return (None, None) # correct line not found, job-originating-host-name unknown 176 176 else : 177 return matchingline.split()[-1] 177 (jobbilling, hostname) = matchingline.split()[-2:] 178 if jobbilling == "-" : 179 jobbilling = "" 180 return (jobbilling, hostname) 178 181 179 182 def doWork(self, policy, printer, user, userpquota) : … … 212 215 ippdatafile.close() 213 216 self.dropPriv() 214 clienthost = ippmessage.get("job-originating-host-name") \ 215 or self.getJobOriginatingHostnameFromPageLog(cupsdconf, printer.Name, user.Name, self.jobid) 217 clienthost = ippmessage.get("job-originating-host-name") 218 billingcode = ippmessage.get("job-billing") 219 if clienthost is None : 220 (billingcode, clienthost) = self.getJobInfosFromPageLog(cupsdconf, printer.Name, user.Name, self.jobid) 216 221 self.logdebug("Client Hostname : %s" % (clienthost or "Unknown")) 217 os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = str(clienthost or "")218 219 # TODO : extract username (double check ?) and billing code too222 self.logdebug("Billing Code : %s" % (billingcode or "None")) 223 os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = clienthost or "" 224 os.environ["PYKOTAJOBBILLING"] = billingcode or "" 220 225 221 226 # enters first phase … … 355 360 action, jobsize, jobprice, self.preserveinputfile, \ 356 361 self.title, self.copies, self.options, clienthost, \ 357 self.jobSizeBytes, self.checksum )362 self.jobSizeBytes, self.checksum, None, billingcode) 358 363 self.printMoreInfo(user, printer, _("Job added to history.")) 359 364