Changeset 822

Show
Ignore:
Timestamp:
02/27/03 23:40:26 (21 years ago)
Author:
jalet
Message:

Correctly handles cases where the printer is off.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykota

    r772 r822  
    1717# 
    1818# $Log$ 
     19# Revision 1.9  2003/02/27 22:40:26  jalet 
     20# Correctly handles cases where the printer is off. 
     21# 
    1922# Revision 1.8  2003/02/09 12:56:53  jalet 
    2023# Internationalization begins... 
     
    108111     
    109112    # Get the page counter directly from the printer itself 
    110     counterbeforejob = kotafilter.requester.getPrinterPageCounter(kotafilter.printerhostname) # TODO use printername instead, make them match from CUPS' config files 
    111      
     113    try : 
     114        counterbeforejob = kotafilter.requester.getPrinterPageCounter(kotafilter.printerhostname) # TODO use printername instead, make them match from CUPS' config files 
     115    except PyKotaRequesterError, msg : 
     116        # can't get actual page counter, assume printer is off, but warns in log 
     117        kotafilter.logger.log_message(msg, "warn") 
     118        printerIsOff = 1 
     119    else :     
     120        printerIsOff = 0 
     121         
    112122    # Get the last page counter and last username from the Quota Storage backend 
    113123    pgc = kotafilter.storage.getPrinterPageCounter(kotafilter.printername)     
     
    117127        kotafilter.logger.log_message(_("Printer %s not registered in the PyKota system") % kotafilter.printername, "warn") 
    118128    else :     
     129        # get last values from Quota Storage 
    119130        (lastpagecounter, lastusername) = (pgc["pagecounter"], pgc["lastusername"]) 
    120131         
     132        # if printer is off then we assume the correct counter value is the last one 
     133        if printerIsOff : 
     134            counterbeforejob = lastpagecounter 
     135             
    121136        # Update the last page counter and last username in the Quota Storage backend 
    122137        # set them to current user and