Show
Ignore:
Timestamp:
01/26/06 16:25:44 (18 years ago)
Author:
jerome
Message:

Added support for the CANCEL command in subprocesses launched from the
overwrite_jobticket directive : this will allow end users to be asked
if they really want to proceed to printing once the new version
of pykoticon will be ready.
Several minor fixes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2624 r2631  
    296296                    self.logdebug("Seen DENY command.") 
    297297                    action = "DENY" 
     298                elif line == "CANCEL" : 
     299                    self.logdebug("Seen CANCEL command.") 
     300                    action = "CANCEL" 
    298301                elif line.startswith("USERNAME=") :     
    299302                    username = line.split("=", 1)[1].strip() 
     
    307310             
    308311            # now overwrite the job's ticket if new data was supplied 
    309             if action : 
     312            if action == "DENY" : 
    310313                self.Action = action 
    311314                self.Reason = _("You are not allowed to print at this time.") 
     315            elif action == "CANCEL" : 
     316                self.Action = action 
     317                self.Reason = _("Print job cancelled.") 
    312318            if username : 
    313319                self.UserName = username 
     
    891897        self.exportPhaseInfo("BEFORE") 
    892898         
    893         if self.Action != "DENY" :  
     899        if self.Action not in ("DENY", "CANCEL") :  
    894900            if self.Printer.MaxJobSize and (self.softwareJobSize > self.Printer.MaxJobSize) : 
    895901                # This printer was set to refuse jobs this large. 
     
    900906                self.Reason = _("You are not allowed to print so many pages on printer %s at this time.") % self.PrinterName 
    901907             
    902         if self.Action != "DENY" : 
     908        if self.Action not in ("DENY", "CANCEL") : 
    903909            if self.User.LimitBy == "noprint" : 
    904910                self.printInfo(_("User %s is not allowed to print at this time.") % self.UserName, "warn") 
     
    906912                self.Reason = _("Your account settings forbid you to print at this time.") 
    907913                 
    908         if self.Action != "DENY" : 
     914        if self.Action not in ("DENY", "CANCEL") : 
    909915            # If printing is still allowed at this time, we 
    910916            # need to extract the billing code information from the database. 
     
    913919            self.getBillingCode() 
    914920             
    915         if self.Action != "DENY" : 
     921        if self.Action not in ("DENY", "CANCEL") : 
    916922            # If printing is still allowed at this time, we 
    917923            # need to check if the job is a dupe or not, and what to do then. 
     
    920926            self.checkIfDupe() 
    921927                     
    922         if self.Action != "DENY" : 
     928        if self.Action not in ("DENY", "CANCEL") : 
    923929            # If printing is still allowed at this time, we 
    924930            # need to check the user's print quota on the current printer. 
     
    962968        if self.Action == "DENY" : 
    963969            self.printInfo(_("Job denied, no accounting will be done.")) 
     970        elif self.Action == "CANCEL" :     
     971            self.printInfo(_("Job cancelled, no accounting will be done.")) 
    964972        else : 
    965973            self.printInfo(_("Job accounting begins.")) 
     
    990998        if self.Action == "DENY" : 
    991999            self.printInfo(_("Job denied, no accounting has been done.")) 
     1000        elif self.Action == "CANCEL" :     
     1001            self.printInfo(_("Job cancelled, no accounting has been done.")) 
    9921002        else : 
    9931003            self.deinstallSigTermHandler() 
     
    10201030                self.JobSize = 0 
    10211031                self.printInfo(_("Job size forced to 0 because printing is denied.")) 
     1032            elif self.Action == "CANCEL" :      
     1033                self.JobSize = 0 
     1034                self.printInfo(_("Job size forced to 0 because printing was cancelled.")) 
    10221035            else :     
    10231036                self.UserPQuota.resetDenyBannerCounter() 
     
    10281041            self.printInfo(_("Job size : %i") % self.JobSize) 
    10291042             
    1030             if (self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE") : 
     1043            if ((self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE")) or \ 
     1044                (self.Action in ("DENY", "CANCEL")) : 
    10311045                self.JobPrice = 0.0 
    10321046            elif (self.User.LimitBy == "nochange") or self.Printer.PassThrough : 
     
    10481062             
    10491063            if hasattr(self, "BillingCode") and self.BillingCode and self.BillingCode.Exists : 
    1050                 if (self.Action != "PROBLEM") or (onbackenderror == "CHARGE") : 
     1064                if (self.Action in ("ALLOW", "WARN")) or \ 
     1065                   ((self.Action == "PROBLEM") and (onbackenderror == "CHARGE")) : 
    10511066                    self.BillingCode.consume(self.JobSize, self.JobPrice) 
    10521067                    self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode)