Changeset 1597
- Timestamp:
- 07/07/04 23:44:15 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pykosd
r1596 r1597 24 24 # 25 25 # $Log$ 26 # Revision 1.3 2004/07/07 21:44:15 jalet 27 # Formatting improvements 28 # 26 29 # Revision 1.2 2004/07/07 14:14:31 jalet 27 30 # Now handles limits by quota in addition to limits by balance … … 40 43 41 44 from pykota.tool import PyKotaTool, PyKotaToolError, crashed 45 46 DURATION = 5 42 47 43 48 if __name__ == "__main__" : … … 58 63 upquotas = [ cmd.storage.getUserPQuota(user, p) for p in printers ] 59 64 nblines = len(upquotas) 60 display = pyosd.osd(colour="# FF0000", timeout=5, shadow=2, lines=nblines)65 display = pyosd.osd(colour="#00FF00", timeout=DURATION, shadow=2, lines=nblines) 61 66 for line in range(nblines) : 62 67 upq = upquotas[line] 63 68 if upq.HardLimit is None : 64 69 if upq.SoftLimit is None : 65 percent = 070 percent = "%s" % upq.PageCounter 66 71 else : 67 percent = (upq.PageCounter * 100) / upq.SoftLimit72 percent = "%s%%" % min((upq.PageCounter * 100) / upq.SoftLimit, 100) 68 73 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) 74 percent = "%s%%" % min((upq.PageCounter * 100) / upq.HardLimit, 100) 75 display.display("Pages used on %s : %s" % (upq.Printer.Name, percent), type=pyosd.TYPE_STRING, line=line) 72 76 else : 73 display = pyosd.osd(colour="#FF0000", timeout=5, shadow=2) 77 if user.AccountBalance <= 0 : 78 color = "#FF0000" 79 else : 80 color = "#00FF00" 81 display = pyosd.osd(colour=color, timeout=DURATION, shadow=2) 74 82 display.display("PyKota Units left : %.2f" % user.AccountBalance, type=pyosd.TYPE_STRING) 75 time.sleep( 6)83 time.sleep(DURATION + 1) 76 84 except : 77 85 cmd.crashed("Strange problem : please report it ASAP to alet@librelogiciel.com")