| 667 | (newusername, newbillingcode, newaction) = self.overwriteJobTicket() |
| 668 | if newusername : |
| 669 | self.printInfo(_("Job ticket overwritten : new username = [%s]") % newusername) |
| 670 | self.username = newusername |
| 671 | if newbillingcode : |
| 672 | self.printInfo(_("Job ticket overwritten : new billing code = [%s]") % newbillingcode) |
| 673 | self.overwrittenBillingCode = newbillingcode |
| 674 | else : |
| 675 | self.overwrittenBillingCode = None |
| 676 | if newaction : |
| 677 | self.printInfo(_("Job ticket overwritten : job will be denied (but a bit later).")) |
| 678 | self.mustDeny = 1 |
| 679 | else : |
| 680 | self.mustDeny = 0 |
| 681 | |
| 713 | |
| 714 | def overwriteJobTicket(self) : |
| 715 | """Should we overwrite the job's ticket (username and billingcode) ?""" |
| 716 | jobticketcommand = self.config.getOverwriteJobTicket(self.printername) |
| 717 | if jobticketcommand is not None : |
| 718 | username = billingcode = action = None |
| 719 | self.logdebug("Launching subprocess [%s] to overwrite the job's ticket." % jobticketcommand) |
| 720 | inputfile = os.popen(jobticketcommand, "r") |
| 721 | for line in inputfile.xreadlines() : |
| 722 | line = line.strip() |
| 723 | if line == "DENY" : |
| 724 | self.logdebug("Seen DENY command.") |
| 725 | action = "DENY" |
| 726 | elif line.startswith("USERNAME=") : |
| 727 | username = line.split("=", 1)[1].strip() |
| 728 | self.logdebug("Seen new username [%s]" % username) |
| 729 | action = None |
| 730 | elif line.startswith("BILLINGCODE=") : |
| 731 | billingcode = line.split("=", 1)[1].strip() |
| 732 | self.logdebug("Seen new billing code [%s]" % billingcode) |
| 733 | action = None |
| 734 | inputfile.close() |
| 735 | return (username, billingcode, action) |
| 736 | else : |
| 737 | return (None, None, None) |