Changeset 2584

Show
Ignore:
Timestamp:
11/15/05 22:47:29 (19 years ago)
Author:
jerome
Message:

Introduce the onbackenderror directive.
Make problems caused by real backend failures appear
as such in the printing history.

Location:
pykota/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2580 r2584  
    988988        self.storage.beginTransaction() 
    989989        try : 
     990            onbackenderror = self.config.getPrinterOnBackendError(self.PrinterName) 
     991            if retcode : 
     992                # NB : We don't send any feedback to the end user. Only the admin 
     993                # has to know that the real CUPS backend failed. 
     994                self.Action = "PROBLEM" 
     995                self.exportReason() 
     996                if onbackenderror == "NOCHARGE" : 
     997                    self.JobSize = 0 
     998                    self.printInfo(_("Job size forced to 0 because the real CUPS backend failed. No accounting will be done."), "warn") 
     999                else :     
     1000                    self.printInfo(_("The real CUPS backend failed, but the job will be accounted for anyway."), "warn") 
     1001                     
    9901002            # retrieve the job size     
    9911003            if self.Action == "DENY" : 
     
    9941006            else :     
    9951007                self.UserPQuota.resetDenyBannerCounter() 
    996                 self.JobSize = self.accounter.getJobSize(self.Printer) 
    997                 self.sanitizeJobSize() 
    998                 self.JobSize += self.BannerSize 
     1008                if (self.Action != "PROBLEM") or (onbackenderror == "CHARGE") :  
     1009                    self.JobSize = self.accounter.getJobSize(self.Printer) 
     1010                    self.sanitizeJobSize() 
     1011                    self.JobSize += self.BannerSize 
    9991012            self.printInfo(_("Job size : %i") % self.JobSize) 
    10001013             
    1001             if (self.User.LimitBy == "nochange") or self.Printer.PassThrough : 
     1014            if (self.Action == "PROBLEM") and (onbackenderror == "NOCHARGE") : 
     1015                self.JobPrice = 0.0 
     1016            elif (self.User.LimitBy == "nochange") or self.Printer.PassThrough : 
    10021017                # no need to update the quota for the current user on this printer 
    10031018                self.printInfo(_("User %s's quota on printer %s won't be modified") % (self.UserName, self.PrinterName)) 
     
    10171032             
    10181033            if hasattr(self, "BillingCode") and self.BillingCode and self.BillingCode.Exists : 
    1019                 self.BillingCode.consume(self.JobSize, self.JobPrice) 
    1020                 self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode) 
     1034                if (self.Action != "PROBLEM") or (onbackenderror == "CHARGE") : 
     1035                    self.BillingCode.consume(self.JobSize, self.JobPrice) 
     1036                    self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode) 
    10211037        except :     
    10221038            self.storage.rollbackTransaction() 
     
    10641080        arguments[2] = self.UserName # in case it was overwritten by external script 
    10651081        # TODO : do something about job-billing option, in case it was overwritten as well... 
     1082        # TODO : do something about the job title : if we are printing a banner and the backend 
     1083        # TODO : uses the job's title to name an output file (cups-pdf:// for example), we're stuck ! 
    10661084         
    10671085        self.logdebug("Starting original backend %s with args %s" % (originalbackend, " ".join(['"%s"' % a for a in arguments]))) 
     
    10951113        if os.WIFEXITED(status) : 
    10961114            status = os.WEXITSTATUS(status) 
     1115            message = "CUPS backend %s returned %d." % \ 
     1116                            (originalbackend, status) 
    10971117            if status : 
    10981118                level = "error" 
     1119                self.Reason = message 
    10991120            else :     
    11001121                level = "info" 
    1101             self.printInfo("CUPS backend %s returned %d." % \ 
    1102                                      (originalbackend, status), level) 
     1122            self.printInfo(message, level) 
    11031123            return status 
    11041124        elif not killed : 
    1105             self.printInfo("CUPS backend %s died abnormally." % \ 
    1106                                originalbackend, "error") 
     1125            self.Reason = "CUPS backend %s died abnormally." % originalbackend 
     1126            self.printInfo(self.Reason, "error") 
    11071127            return -1 
    11081128        else : 
    1109             self.printInfo("CUPS backend %s was killed." % \ 
    1110                                originalbackend, "warn") 
     1129            self.Reason = "CUPS backend %s was killed." % originalbackend 
     1130            self.printInfo(self.Reason, "warn") 
    11111131            return 1 
    11121132         
  • pykota/trunk/bin/waitprinter.sh

    r2146 r2584  
    7575        ##log_msg "`ls -la /var/spool/{cups,samba}`" 
    7676        log_msg "Pykota Phase: ${PYKOTAPHASE}" 
    77         if [ x$PYKOTASTATUS != "xCANCELLED" ] && [ x$PYKOTAACTION != "xDENY" ] && [ x$PYKOTAPHASE = "xAFTER" ] ; then 
     77        if [ x$PYKOTASTATUS != "xCANCELLED" ] && [ x$PYKOTAACTION = "xALLOW" ] && [ x$PYKOTAPHASE = "xAFTER" ] ; then 
    7878                printing_wait "${printer}" 
    7979        fi 
  • pykota/trunk/cgi-bin/printquota.cgi

    r2578 r2584  
    228228                        elif job.JobAction == "WARN" :     
    229229                            oddevenclass = "warn" 
     230                        elif job.JobAction == "PROBLEM" : 
     231                            oddevenclass = "problem" 
    230232                        username_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "username" : job.UserName}), job.UserName) 
    231233                        printername_url = '<a href="%s?%s">%s</a>' % (os.environ.get("SCRIPT_NAME", ""), urllib.urlencode({"history" : 1, "printername" : job.PrinterName}), job.PrinterName) 
  • pykota/trunk/NEWS

    r2581 r2584  
    2222PyKota NEWS : 
    2323        
     24    - 1.24alpha2 : 
     25     
     26        - Introduce the "onbackenderror" directive in pykota.conf, to 
     27          control if the user must be charged or not whenever a real 
     28          CUPS backend fails. The default value is 'nocharge'. 
     29          Set it to 'charge' if you think your users can cause a CUPS 
     30          backend to fail. 
     31           
     32        - Now mark original backends related problems as such in the  
     33          printing history. Modified printquota.cgi and pykota.css 
     34          to make them be more visible. 
     35           
    2436    - 1.24alpha1 : 
    2537     
  • pykota/trunk/pykota/accounters/pjl.py

    r2523 r2584  
    173173        try : 
    174174            if (os.environ.get("PYKOTASTATUS") != "CANCELLED") and \ 
    175                (os.environ.get("PYKOTAACTION") != "DENY") and \ 
     175               (os.environ.get("PYKOTAACTION") == "ALLOW") and \ 
    176176               (os.environ.get("PYKOTAPHASE") == "AFTER") and \ 
    177177               self.parent.filter.JobSizeBytes : 
  • pykota/trunk/pykota/accounters/snmp.py

    r2506 r2584  
    175175            try : 
    176176                if (os.environ.get("PYKOTASTATUS") != "CANCELLED") and \ 
    177                    (os.environ.get("PYKOTAACTION") != "DENY") and \ 
     177                   (os.environ.get("PYKOTAACTION") == "ALLOW") and \ 
    178178                   (os.environ.get("PYKOTAPHASE") == "AFTER") and \ 
    179179                   self.parent.filter.JobSizeBytes : 
  • pykota/trunk/pykota/version.py

    r2564 r2584  
    2222# 
    2323 
    24 __version__ = "1.24alpha1_unofficial" 
     24__version__ = "1.24alpha2_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS." 
  • pykota/trunk/stylesheets/pykota.css

    r2478 r2584  
    4040      } 
    4141       
     42.problem {      
     43        background-color: #DEBDEB; 
     44      } 
     45       
    4246.pykotacolsheader {       
    4347        background-color: #AAAAAA;