Changeset 1596 for pykota/trunk

Show
Ignore:
Timestamp:
07/07/04 16:14:31 (20 years ago)
Author:
jalet
Message:

Now handles limits by quota in addition to limits by balance

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykosd

    r1595 r1596  
    2424# 
    2525# $Log$ 
     26# Revision 1.2  2004/07/07 14:14:31  jalet 
     27# Now handles limits by quota in addition to limits by balance 
     28# 
    2629# Revision 1.1  2004/07/07 13:21:27  jalet 
    2730# Introduction of the pykosd command 
     
    5154            if not user.Exists : 
    5255                raise PyKotaToolError, "User %s doesn't exist in PyKota's database." % uname 
    53             display = pyosd.osd(colour="#FF0000", timeout=5, shadow=2) 
    54             display.display("PyKota Units left : %.2f" % user.AccountBalance, type=pyosd.TYPE_STRING)     
     56            if user.LimitBy == "quota" :     
     57                printers = cmd.storage.getMatchingPrinters("*") 
     58                upquotas = [ cmd.storage.getUserPQuota(user, p) for p in printers ] 
     59                nblines = len(upquotas) 
     60                display = pyosd.osd(colour="#FF0000", timeout=5, shadow=2, lines=nblines) 
     61                for line in range(nblines) : 
     62                    upq = upquotas[line] 
     63                    if upq.HardLimit is None : 
     64                        if upq.SoftLimit is None : 
     65                            percent = 0 
     66                        else :         
     67                            percent = (upq.PageCounter * 100) / upq.SoftLimit 
     68                    else :         
     69                        percent = (upq.PageCounter * 100) / upq.HardLimit 
     70                    percent = min(percent, 100) 
     71                    display.display("Pages used on %s : %s%%" % (upq.Printer.Name, percent), type=pyosd.TYPE_STRING, line=line)     
     72            else : 
     73                display = pyosd.osd(colour="#FF0000", timeout=5, shadow=2) 
     74                display.display("PyKota Units left : %.2f" % user.AccountBalance, type=pyosd.TYPE_STRING)     
    5575            time.sleep(6) 
    5676        except :