Changeset 2277

Show
Ignore:
Timestamp:
06/03/05 10:49:34 (19 years ago)
Author:
jerome
Message:

Fixed incorrect loop counter in pjl and snmp accounters.
Now uses USTATUS in the pjl accounter to workaround printers
which switch to 'busy' state when we request their status
(meaning they were always busy) : seems to work just fine
now on my HP2300N.

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r2276 r2277  
    2222PyKota NEWS : 
    2323        
     24    - 1.23alpha7 : 
     25     
     26        - Improvements to the internal PJL and SNMP accounter : now should 
     27          support more printers and waste less time. 
     28           
    2429    - 1.23alpha6 : 
    2530     
  • pykota/trunk/pykota/accounters/pjl.py

    r2205 r2277  
    2929import signal 
    3030 
    31 ITERATIONDELAY = 1.0   # 1 Second 
     31# NB : in fact these variables don't do much, since the time  
     32# is in fact wasted in the sock.recv() blocking call, with the timeout 
     33ITERATIONDELAY = 1   # 1 Second 
    3234STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 
    3335 
    34 pjlMessage = "\033%-12345X@PJL USTATUSOFF\r\n@PJL INFO STATUS\r\n@PJL INFO PAGECOUNT\r\n\033%-12345X" 
     36# Here's the real thing : 
     37TIMEOUT = 3 
     38 
     39# Old method : pjlMessage = "\033%-12345X@PJL USTATUSOFF\r\n@PJL INFO STATUS\r\n@PJL INFO PAGECOUNT\r\n\033%-12345X" 
     40# Here's a new method, which seems to work fine on my HP2300N, while the  
     41# previous one didn't. 
     42# TODO : We could also experiment with USTATUS JOB=ON and we would know for sure  
     43# when the job is finished, without having to poll the printer repeatedly. 
     44pjlMessage = "\033%-12345X@PJL USTATUS DEVICE=ON\r\n@PJL INFO STATUS\r\n@PJL INFO PAGECOUNT\r\n@PJL USTATUS DEVICE=OFF\033%-12345X" 
    3545pjlStatusValues = { 
    3646                    "10000" : "Powersave Mode", 
     
    7686                while (self.timedout == 0) or (actualpagecount is None) or (self.printerStatus is None) : 
    7787                    signal.signal(signal.SIGALRM, self.alarmHandler) 
    78                     signal.alarm(3) 
     88                    signal.alarm(TIMEOUT) 
    7989                    try : 
    8090                        answer = sock.recv(1024) 
     
    8393                    else :     
    8494                        readnext = 0 
     95                        self.parent.filter.logdebug("PJL answer : %s" % repr(answer)) 
    8596                        for line in [l.strip() for l in answer.split()] :  
    8697                            if line.startswith("CODE=") : 
     
    128139            if idle_flag :     
    129140                idle_num += 1 
    130                 if idle_num > STABILIZATIONDELAY : 
     141                if idle_num >= STABILIZATIONDELAY : 
    131142                    # printer status is stable, we can exit 
    132143                    break 
  • pykota/trunk/pykota/accounters/snmp.py

    r2205 r2277  
    2323# 
    2424 
    25 ITERATIONDELAY = 1.0   # 1 Second 
     25ITERATIONDELAY = 1.5   # 1.5 Second 
    2626STABILIZATIONDELAY = 3 # We must read three times the same value to consider it to be stable 
    2727 
     
    159159                if idle_flag :     
    160160                    idle_num += 1 
    161                     if idle_num > STABILIZATIONDELAY : 
     161                    if idle_num >= STABILIZATIONDELAY : 
    162162                        # printer status is stable, we can exit 
    163163                        break 
  • pykota/trunk/pykota/version.py

    r2276 r2277  
    2222# 
    2323 
    24 __version__ = "1.23alpha6_unofficial" 
     24__version__ = "1.23alpha7_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."