Changeset 966

Show
Ignore:
Timestamp:
04/26/03 10:41:24 (21 years ago)
Author:
jalet
Message:

Small code reorganisation (UNTESTED) to allow pluggable accounting
methods in the future.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykota

    r963 r966  
    2323# 
    2424# $Log$ 
     25# Revision 1.28  2003/04/26 08:41:24  jalet 
     26# Small code reorganisation (UNTESTED) to allow pluggable accounting 
     27# methods in the future. 
     28# 
    2529# Revision 1.27  2003/04/25 09:23:47  jalet 
    2630# Debug message passed through ! 
     
    190194            return kotafilter.removeJob() 
    191195     
    192     # Get the page counter directly from the printer itself 
    193     # Tries MAXTRIES times, sleeping two seconds each time, in case the printer is sleeping. 
    194     # This was seen with my Apple LaserWriter 16/600 PS which doesn't answer before having warmed up. 
    195     for i in range(MAXTRIES) : 
    196         try : 
    197             counterbeforejob = kotafilter.requester.getPrinterPageCounter(kotafilter.printerhostname) 
    198         except PyKotaRequesterError, msg : 
    199             # can't get actual page counter, assume printer is off or warming up 
    200             # log the message anyway. 
    201             kotafilter.logger.log_message("%s" % msg, "warn") 
    202             counterbeforejob = None 
    203             printerIsOff = 1 
    204         else :     
    205             # printer answered, it is on so we can exit the loop 
    206             printerIsOff = 0 
    207             break 
    208         time.sleep(TIMETOSLEEP)     
    209          
    210196    # Get the last page counter and last username from the Quota Storage backend 
    211197    printerid = kotafilter.storage.getPrinterId(kotafilter.printername) 
     
    230216                return kotafilter.removeJob() 
    231217        else : 
     218            # Get the page counter directly from the printer itself 
     219            # Tries MAXTRIES times, sleeping two seconds each time, in case the printer is sleeping. 
     220            # This was seen with my Apple LaserWriter 16/600 PS which doesn't answer before having warmed up. 
     221            for i in range(MAXTRIES) : 
     222                try : 
     223                    counterbeforejob = kotafilter.requester.getPrinterPageCounter(kotafilter.printerhostname) 
     224                except PyKotaRequesterError, msg : 
     225                    # can't get actual page counter, assume printer is off or warming up 
     226                    # log the message anyway. 
     227                    kotafilter.logger.log_message("%s" % msg, "warn") 
     228                    counterbeforejob = None 
     229                    printerIsOff = 1 
     230                else :     
     231                    # printer answered, it is on so we can exit the loop 
     232                    printerIsOff = 0 
     233                    break 
     234                time.sleep(TIMETOSLEEP)     
     235         
    232236            # get last job information for this printer 
    233237            pgc = kotafilter.storage.getPrinterPageCounter(printerid)