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

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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)