Changeset 3162 for pykota/trunk

Show
Ignore:
Timestamp:
04/14/07 10:50:47 (18 years ago)
Author:
jerome
Message:

Added the 'skipinitialwait' directive to pykota.conf.
This halves the inter-job delay when using hardware accounting
when set.

Location:
pykota/trunk
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r3158 r3162  
    671671accounter: software() 
    672672 
    673  
     673# Should we ensure that the printer really is idle before  
     674# sending the job's datas to it ? 
     675# 
     676# This directive is only used when you use an internal  
     677#�hardware accounting mechanism, like hardware(snmp) or 
     678# hardware(pjl), and is not used for external hardware 
     679# accounting mechanisms or for software or ink accounting. 
     680# 
     681# If PyKota and CUPS are properly configured, i.e. a single 
     682# computer (the print server) can access to a particular physical  
     683# printer, or all CUPS+PyKota print servers which access to the 
     684# same physical printer share a common network directory used 
     685# by PyKota to lock this printer resource, then it is not necessary 
     686# to really ensure the printer is idle before the job, because 
     687# this is already the case : we already wait at the end of the 
     688# preceding job for the printer to be idle before reading its 
     689# internal page counter. So setting this value to Yes usually 
     690# saves a lot of time between jobs, generally around 30 seconds. 
     691# 
     692# If you're not sure, leave this value to the default which is No, 
     693# meaning that before sending the job's datas to the printer, PyKota 
     694# will ensure this printer is in idle state. 
     695# 
     696# If not defined, a value of No is assumed. 
     697#  
     698# This value can be set either globally or on a per printer basis 
     699# If both are defined, the printer option has priority. 
     700# 
     701# Sane default : 
     702# 
     703skipinitialwait : no 
    674704 
    675705# What is the "pre"-accounter used for precomputing the job's size. 
  • pykota/trunk/pykota/accounters/hardware.py

    r3133 r3162  
    109109           The external command must report the life time page number of the printer on stdout. 
    110110        """ 
     111        skipinitialwait = self.filter.config.getPrinterSkipInitialWait(printer) 
    111112        commandline = self.arguments.strip() % locals() 
    112113        cmdlower = commandline.lower() 
    113114        if (cmdlower == "snmp") or cmdlower.startswith("snmp:") : 
    114             return snmp.Handler(self, printer).retrieveInternalPageCounter() 
     115            return snmp.Handler(self, printer, skipinitialwait).retrieveInternalPageCounter() 
    115116        elif (cmdlower == "pjl") or cmdlower.startswith("pjl:") : 
    116             return pjl.Handler(self, printer).retrieveInternalPageCounter() 
     117            return pjl.Handler(self, printer, skipinitialwait).retrieveInternalPageCounter() 
    117118             
    118119        if printer is None : 
  • pykota/trunk/pykota/accounters/pjl.py

    r3133 r3162  
    5858class Handler : 
    5959    """A class for PJL print accounting.""" 
    60     def __init__(self, parent, printerhostname) : 
     60    def __init__(self, parent, printerhostname, skipinitialwait=False) : 
    6161        self.parent = parent 
    6262        self.printerHostname = printerhostname 
     63        self.skipinitialwait = skipinitialwait 
    6364        try : 
    6465            self.port = int(self.parent.arguments.split(":")[1].strip()) 
     
    181182        while 1 : 
    182183            self.retrievePJLValues() 
     184            if (self.printerInternalPageCounter is not None) \ 
     185               and self.skipinitialwait \ 
     186               and (os.environ.get("PYKOTAPHASE") == "BEFORE") : 
     187                self.parent.filter.logdebug("No need to wait for the printer to be idle, this should be the case already.") 
     188                return  
    183189            idle_flag = 0 
    184190            if self.printerStatus in ('10000', '10001', '35078', '40000') : 
  • pykota/trunk/pykota/accounters/snmp.py

    r3161 r3162  
    109109class BaseHandler : 
    110110    """A class for SNMP print accounting.""" 
    111     def __init__(self, parent, printerhostname) : 
     111    def __init__(self, parent, printerhostname, skipinitialwait=False) : 
    112112        self.parent = parent 
    113113        self.printerHostname = printerhostname 
     114        self.skipinitialwait = skipinitialwait 
    114115        try : 
    115116            self.community = self.parent.arguments.split(":")[1].strip() 
     
    210211        while 1 : 
    211212            self.retrieveSNMPValues() 
     213            if (self.printerInternalPageCounter is not None) \ 
     214               and self.skipinitialwait \ 
     215               and (os.environ.get("PYKOTAPHASE") == "BEFORE") : 
     216                self.parent.filter.logdebug("No need to wait for the printer to be idle, this should be the case already.") 
     217                return  
    212218            pstatusAsString = printerStatusValues.get(self.printerStatus) 
    213219            dstatusAsString = deviceStatusValues.get(self.deviceStatus) 
  • pykota/trunk/pykota/config.py

    r3158 r3162  
    691691            else : 
    692692                del branches[k] # empty value disables a global option 
    693                  
    694693        return branches 
     694         
     695    def getPrinterSkipInitialWait(self, printername) : 
     696        """Returns True if we want to skip the initial waiting loop, else False.""" 
     697        try : 
     698            return self.isTrue(self.getPrinterOption(printername, "skipinitialwait")) 
     699        except PyKotaConfigError : 
     700            return False 
  • pykota/trunk/pykota/version.py

    r3153 r3162  
    2222# 
    2323 
    24 __version__ = "1.26alpha4_unofficial" 
     24__version__ = "1.26alpha5_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS." 
  • pykota/trunk/TODO

    r3157 r3162  
    2828          minimal price. The value wouldn't be used (yet?) for  
    2929          normal page accounting. 
    30            
    31         - Allow for configurable setting wrt the fact that PyKota waits 
    32           for the printer being idle before asking for printer's internal  
    33           page counter before sending any data to the printer : if 
    34           the print server is correctly configured (i.e. only PyKota can 
    35           access to this particular printer), then we know for sure the 
    36           printer will be idle at this time, because we wait for it 
    37           to become idle again after having printed the job => we could 
    38           save up to 50% of waiting time, and handle more jobs 
    39           in the same time. 
    4030           
    4131        - --orderby and --order ASC|DESC for dumpykota (or --asc | --desc)