Show
Ignore:
Timestamp:
02/16/05 01:29:33 (19 years ago)
Author:
jalet
Message:

Fixed the maxdenybanners directive.
Introduced the denyduplicates directive.
Fixed some database related glitches.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2062 r2066  
    2424# 
    2525# $Log$ 
     26# Revision 1.89  2005/02/16 00:29:33  jalet 
     27# Fixed the maxdenybanners directive. 
     28# Introduced the denyduplicates directive. 
     29# Fixed some database related glitches. 
     30# 
    2631# Revision 1.88  2005/02/14 23:39:50  jalet 
    2732# Introduces the new 'trustjobsize' directive to workaround some printers 
     
    534539            self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
    535540             
    536             # if no data to pass to real backend, probably a filter 
    537             # higher in the chain failed because of a misconfiguration. 
    538             # we deny the job in this case (nothing to print anyway) 
    539541            if not self.jobSizeBytes : 
     542                # if no data to pass to real backend, probably a filter 
     543                # higher in the chain failed because of a misconfiguration. 
     544                # we deny the job in this case (nothing to print anyway) 
    540545                self.printMoreInfo(user, printer, _("Job contains no data. Printing is denied."), "warn") 
    541546                action = "DENY" 
     547            elif self.config.getDenyDuplicates(printer.Name) \ 
     548                 and printer.LastJob.Exists \ 
     549                 and (printer.LastJob.UserName == user.Name) \ 
     550                 and (printer.LastJob.JobMD5Sum == self.checksum) : 
     551                self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 
     552                action = "DENY"  
    542553            else :     
    543554                # checks the user's quota 
     
    557568            accountbanner = self.config.getAccountBanner(printer.Name) 
    558569            if accountbanner in ["ENDING", "NONE"] : 
    559                 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) : 
     570                if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 
    560571                    self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 
    561572                else : 
    562573                    if action == 'DENY' : 
    563                         userpquota.warn() # increments the warning counter 
     574                        self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 
     575                        userpquota.incDenyBannerCounter() # increments the warning counter 
    564576                        self.exportUserInfo(userpquota) 
    565577                    banner = self.startingBanner(printer.Name) 
     
    573585            # handle starting banner pages during accounting 
    574586            if accountbanner in ["STARTING", "BOTH"] : 
    575                 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) : 
     587                if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 
    576588                    self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 
    577589                else : 
    578590                    if action == 'DENY' : 
    579                         userpquota.warn() # increments the warning counter 
     591                        self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 
     592                        userpquota.incDenyBannerCounter() # increments the warning counter 
    580593                        self.exportUserInfo(userpquota) 
    581594                    banner = self.startingBanner(printer.Name) 
     
    604617            # handle ending banner pages during accounting 
    605618            if accountbanner in ["ENDING", "BOTH"] : 
    606                 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) : 
     619                if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 
    607620                    self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 
    608621                else : 
    609622                    if action == 'DENY' : 
    610                         userpquota.warn() # increments the warning counter 
     623                        self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 
     624                        userpquota.incDenyBannerCounter() # increments the warning counter 
    611625                        self.exportUserInfo(userpquota) 
    612626                    banner = self.endingBanner(printer.Name) 
     
    626640                self.printMoreInfo(user, printer, _("Job size forced to 0 because printing is denied.")) 
    627641            else :     
     642                userpquota.resetDenyBannerCounter() 
    628643                jobsize = self.accounter.getJobSize(printer) 
    629644                if self.softwareJobSize and (jobsize != self.softwareJobSize) : 
     
    664679            # handle ending banner pages after accounting ends 
    665680            if accountbanner in ["STARTING", "NONE"] : 
    666                 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) : 
     681                if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 
    667682                    self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 
    668683                else : 
    669684                    if action == 'DENY' : 
    670                         userpquota.warn() # increments the warning counter 
     685                        self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 
     686                        userpquota.incDenyBannerCounter() # increments the warning counter 
    671687                        self.exportUserInfo(userpquota) 
    672688                    banner = self.endingBanner(printer.Name)