Changeset 2692 for pykota/trunk/pykota

Show
Ignore:
Timestamp:
02/14/06 16:18:45 (18 years ago)
Author:
jerome
Message:

Added the 'duplicatesdelay' and 'balancezero' directives.

Location:
pykota/trunk/pykota
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/config.py

    r2635 r2692  
    439439            raise PyKotaConfigError, _("Invalid poor man's threshold %s") % pm 
    440440             
     441    def getBalanceZero(self) :     
     442        """Returns the value of the zero for balance limitation.""" 
     443        try : 
     444            bz = self.getGlobalOption("balancezero") 
     445        except PyKotaConfigError :     
     446            bz = 0.0    # default value, zero is 0.0 
     447        try : 
     448            return float(bz) 
     449        except (TypeError, ValueError) :     
     450            raise PyKotaConfigError, _("Invalid balancezero value %s") % bz 
     451             
    441452    def getPoorWarn(self) :     
    442453        """Returns the poor man's warning message.""" 
     
    516527                # it's a command to run. 
    517528                return denyduplicates 
     529                 
     530    def getDuplicatesDelay(self, printername) :           
     531        """Returns the number of seconds after which two identical jobs are not considered a duplicate anymore.""" 
     532        try :  
     533            duplicatesdelay = self.getPrinterOption(printername, "duplicatesdelay") 
     534        except PyKotaConfigError :     
     535            return 0 
     536        else :     
     537            try : 
     538                return int(duplicatesdelay) 
     539            except (TypeError, ValueError) : 
     540                raise PyKotaConfigError, _("Incorrect value %s for the duplicatesdelay directive in section %s") % (str(duplicatesdelay), printername) 
    518541         
    519542    def getWinbindSeparator(self) :           
  • pykota/trunk/pykota/reporter.py

    r2622 r2692  
    100100        else : 
    101101            if entry.LimitBy.lower() == "balance" : 
    102                 if balance == 0.0 : 
     102                balancezero = self.tool.config.getBalanceZero() 
     103                if balance == balancezero : 
    103104                    if entry.OverCharge > 0 : 
    104105                        datelimit = "DENY" 
     
    109110                        datelimit = "" 
    110111                        reached = "-B" 
    111                 elif balance < 0 : 
     112                elif balance < balancezero : 
    112113                    datelimit = "DENY" 
    113114                    reached = "+B" 
  • pykota/trunk/pykota/tool.py

    r2657 r2692  
    458458            if enforcement == "STRICT" :  
    459459                val -= self.softwareJobPrice # use precomputed size. 
    460             if val <= 0.0 : 
     460            balancezero = self.config.getBalanceZero() 
     461            if val <= balancezero : 
    461462                action = "DENY" 
    462463            elif val <= self.config.getPoorMan() :     
     
    464465            else :     
    465466                action = "ALLOW" 
    466             if (enforcement == "STRICT") and (val == 0.0) : 
     467            if (enforcement == "STRICT") and (val == balancezero) : 
    467468                action = "WARN" # we can still print until account is 0 
    468469        else : 
     
    549550                    if enforcement == "STRICT" :  
    550551                        val -= self.softwareJobPrice # use precomputed size. 
    551                     if val <= 0.0 : 
     552                    balancezero = self.config.getBalanceZero()     
     553                    if val <= balancezero : 
    552554                        action = "DENY" 
    553555                    elif val <= self.config.getPoorMan() :     
     
    555557                    else : 
    556558                        action = "ALLOW" 
    557                     if (enforcement == "STRICT") and (val == 0.0) : 
     559                    if (enforcement == "STRICT") and (val == balancezero) : 
    558560                        action = "WARN" # we can still print until account is 0 
    559561                return action     
  • pykota/trunk/pykota/version.py

    r2668 r2692  
    2222# 
    2323 
    24 __version__ = "1.24alpha11_unofficial" 
     24__version__ = "1.24alpha12_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS."