Changeset 2062 for pykota/trunk

Show
Ignore:
Timestamp:
02/15/05 00:39:50 (20 years ago)
Author:
jalet
Message:

Introduces the new 'trustjobsize' directive to workaround some printers
generating unstable internal page counter values when queried through SNMP.

Location:
pykota/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2060 r2062  
    2424# 
    2525# $Log$ 
     26# Revision 1.88  2005/02/14 23:39:50  jalet 
     27# Introduces the new 'trustjobsize' directive to workaround some printers 
     28# generating unstable internal page counter values when queried through SNMP. 
     29# 
    2630# Revision 1.87  2005/02/14 22:53:44  jalet 
    2731# Now always precomputes the job's size with the internal PDL parser, and not 
     
    625629                if self.softwareJobSize and (jobsize != self.softwareJobSize) : 
    626630                    self.printInfo(_("Beware : computed job size (%s) != precomputed job size (%s)") % (jobsize, self.softwareJobSize), "error") 
     631                    (limit, replacement) = self.config.getTrustJobSize(printer.Name) 
     632                    if limit is None : 
     633                        self.printInfo(_("The job size will be trusted anyway according to the 'trustjobsize' directive"), "warn") 
     634                    else : 
     635                        if jobsize <= limit : 
     636                            self.printInfo(_("The job size will be trusted because it is inferior to the 'trustjobsize' directive's limit %s") % limit, "warn") 
     637                        else : 
     638                            self.printInfo(_("The job size will be modified according to the 'trustjobsize' directive : %s") % replacement, "warn") 
     639                            if replacement == "PRECOMPUTED" : 
     640                                jobsize = self.softwareJobSize 
     641                            else :     
     642                                jobsize = replacement 
    627643                jobsize += bannersize     
    628644            self.printMoreInfo(user, printer, _("Job size : %i") % jobsize) 
  • pykota/trunk/bin/lprngpykota

    r2060 r2062  
    2424# 
    2525# $Log$ 
     26# Revision 1.16  2005/02/14 23:39:50  jalet 
     27# Introduces the new 'trustjobsize' directive to workaround some printers 
     28# generating unstable internal page counter values when queried through SNMP. 
     29# 
    2630# Revision 1.15  2005/02/14 22:53:44  jalet 
    2731# Now always precomputes the job's size with the internal PDL parser, and not 
     
    254258            if self.softwareJobSize and (jobsize != self.softwareJobSize) : 
    255259                self.printInfo(_("Beware : computed job size (%s) != precomputed job size (%s)") % (jobsize, self.softwareJobSize), "error") 
     260                (limit, replacement) = self.config.getTrustJobSize(printer.Name) 
     261                if limit is None : 
     262                    self.printInfo(_("The job size will be trusted anyway according to the 'trustjobsize' directive"), "warn") 
     263                else : 
     264                    if jobsize <= limit : 
     265                        self.printInfo(_("The job size will be trusted because it is inferior to the 'trustjobsize' directive's limit %s") % limit, "warn") 
     266                    else : 
     267                        self.printInfo(_("The job size will be modified according to the 'trustjobsize' directive : %s") % replacement, "warn") 
     268                        if replacement == "PRECOMPUTED" : 
     269                            jobsize = self.softwareJobSize 
     270                        else :     
     271                            jobsize = replacement 
    256272             
    257273            self.printMoreInfo(user, printer, _("Job size : %i") % jobsize) 
  • pykota/trunk/conf/pykota.conf.sample

    r2054 r2062  
    603603#                else is not set. 
    604604# PYKOTAJOBSIZEBYTES : contains the job's size in bytes. Always available. 
    605 # PYKOTAPRECOMPUTEDJOBSIZE : contains the precomputed job's size (with enforcement: strict) 
    606 # PYKOTAPRECOMPUTEDJOBPRICE : contains the precomputed job's price (with enforcement: strict) 
     605# PYKOTAPRECOMPUTEDJOBSIZE : contains the precomputed job's size 
     606# PYKOTAPRECOMPUTEDJOBPRICE : contains the precomputed job's price 
    607607# PYKOTAJOBORIGINATINGHOSTNAME : contains the client's hostname if  
    608608#                                it is possible to retrieve it. 
     
    730730# enforcement : laxist 
    731731enforcement : strict 
     732 
     733# Should we trust the job size on this printer ? 
     734# 
     735# "yes" is the default, the jobsize, either computed 
     736# by the hardware or by software is trusted. 
     737# 
     738# ">N:precomputed" : uses the precomputed value if jobsize > N pages 
     739# ">N:25" : uses 25 if jobsize is >N pages 
     740# 
     741# General form : ">n:m" where n is a positive integer, and m is  
     742# either the word 'precomputed' or a positive integer. 
     743# The special form "yes" is also accepted and is the default. 
     744# 
     745# This directive can be set either globally or on a per printer 
     746# basis. Use this directive when hardware accounting for a particular 
     747# printer produces some glitches due to the printer returning  
     748# incorrect answers. 
     749# 
     750# NB : DON'T MODIFY THIS IF YOU DON'T NEED TO. THIS IS ONLY TO BE USED 
     751# AS A WORKAROUND FOR SOME PRINTERS. IT'S PROBABLY BETTER TO ALWAYS 
     752# SET THIS DIRECTIVE TO 'yes'. THIS DIRECTIVE WILL ONLY BE HONORED  
     753# IF PYKOTA DETECTS A DIFFERENCE BETWEEN THE PRECOMPUTED JOB SIZE 
     754# AND THE JOB SIZE AS COMPUTED BY PYKOTA EITHER USING HARDWARE OR 
     755# SOFTWARE. 
     756trustjobsize : yes 
  • pykota/trunk/NEWS

    r2054 r2062  
    2222PyKota NEWS : 
    2323        
     24    - 1.21alpha25 : 
     25     
     26        - The job's size is now always precomputed, even when 
     27          'enforcement' is not set to 'strict'. 
     28           
     29        - Introduction of the new 'trustjobsize' configuration directive 
     30          to workaround some problematic printers. See the sample 
     31          configuration file for details. 
     32           
    2433    - 1.21alpha24 : 
    2534     
  • pykota/trunk/pykota/config.py

    r2054 r2062  
    2222# 
    2323# $Log$ 
     24# Revision 1.60  2005/02/14 23:39:50  jalet 
     25# Introduces the new 'trustjobsize' directive to workaround some printers 
     26# generating unstable internal page counter values when queried through SNMP. 
     27# 
    2428# Revision 1.59  2005/02/13 22:02:29  jalet 
    2529# Big database structure changes. Upgrade script is now included as well as 
     
    630634        except PyKotaConfigError : 
    631635            return None 
     636             
     637    def getTrustJobSize(self, printername) : 
     638        """Returns the normalized value of the trustjobsize's directive.""" 
     639        try : 
     640            value = self.getPrinterOption(printername, "trustjobsize").strip().upper() 
     641        except PyKotaConfigError : 
     642            return (None, "YES") 
     643        else :     
     644            if value == "YES" : 
     645                return (None, "YES") 
     646            try :     
     647                (limit, replacement) = [p.strip() for p in value.split(">")[1].split(":")] 
     648                limit = int(limit) 
     649                try : 
     650                    replacement = int(replacement)  
     651                except ValueError :     
     652                    if replacement != "PRECOMPUTED" : 
     653                        raise 
     654                if limit < 0 : 
     655                    raise ValueError 
     656                if (replacement != "PRECOMPUTED") and (replacement < 0) : 
     657                    raise ValueError 
     658            except (IndexError, ValueError, TypeError) : 
     659                raise PyKotaConfigError, _("Option trustjobsize for printer %s is incorrect") % printername 
     660            return (limit, replacement)     
  • pykota/trunk/pykota/version.py

    r2054 r2062  
    2222# 
    2323 
    24 __version__ = "1.21alpha24_unofficial" 
     24__version__ = "1.21alpha25_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""