Changeset 2388 for pykota/trunk/bin/cupspykota
- Timestamp:
- 07/27/05 15:17:28 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2314 r2388 220 220 (chtype, clienthost) = ippmessage.operation_attributes.get("job-originating-host-name", \ 221 221 ippmessage.job_attributes.get("job-originating-host-name", (None, None))) 222 (jbtype, b illingcode) = ippmessage.job_attributes.get("job-billing", (None, None))222 (jbtype, bcode) = ippmessage.job_attributes.get("job-billing", (None, None)) 223 223 except AttributeError : 224 224 clienthost = None 225 b illingcode = None225 bcode = None 226 226 if clienthost is None : 227 (b illingcode, clienthost) = self.getJobInfosFromPageLog(cupsdconf, printer.Name, user.Name, self.jobid)227 (bcode, clienthost) = self.getJobInfosFromPageLog(cupsdconf, printer.Name, user.Name, self.jobid) 228 228 self.logdebug("Client Hostname : %s" % (clienthost or "Unknown")) 229 self.logdebug("Billing Code : %s" % (b illingcode or "None"))229 self.logdebug("Billing Code : %s" % (bcode or "None")) 230 230 231 231 os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = str(clienthost or "") 232 os.environ["PYKOTAJOBBILLING"] = str(b illingcode or "")232 os.environ["PYKOTAJOBBILLING"] = str(bcode or "") 233 233 234 234 # enters first phase … … 269 269 else : 270 270 self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is allowed by subprocess."), "warn") 271 action = "ALLOW" # just to be sure, in the case the external command returns something else...271 action = self.warnUserPQuota(userpquota) 272 272 else : 273 273 # checks the user's quota 274 274 action = self.warnUserPQuota(userpquota) 275 276 # Now handle the billing code 277 if bcode is not None : 278 billingcode = self.storage.getBillingCode(bcode) 279 if billingcode.Exists : 280 self.logdebug("Billing code [%s] exists in database." % bcode) 281 else : 282 msg = "Unknown billing code [%s] : " % bcode 283 (newaction, script) = self.config.getUnknownBillingCode(printer.Name) 284 if newaction == "CREATE" : 285 self.logdebug(msg + "will be created.") 286 billingcode = self.storage.addBillingCode(bcode) 287 if billingcode.Exists : 288 self.logdebug(msg + "has been created.") 289 else : 290 self.printInfo(msg + "couldn't be created.", "error") 291 else : 292 self.logdebug(msg + "job will be denied.") 293 action = newaction 294 if script is not None : 295 self.logdebug(msg + "launching subprocess [%s] to notify user." % script) 296 os.system(script) 297 else : 298 billingcode = None 275 299 276 300 # exports some new environment variables … … 386 410 action, jobsize, jobprice, self.preserveinputfile, \ 387 411 self.title, self.copies, self.options, clienthost, \ 388 self.jobSizeBytes, self.checksum, None, b illingcode)412 self.jobSizeBytes, self.checksum, None, bcode) 389 413 self.printMoreInfo(user, printer, _("Job added to history.")) 390 414 415 if billingcode and billingcode.Exists : 416 billingcode.consume(jobsize, jobprice) 417 self.printMoreInfo(user, printer, _("Billing code %s was updated.") % billingcode.BillingCode) 418 391 419 # exports some new environment variables 392 420 os.environ["PYKOTAJOBSIZE"] = str(jobsize)