Changeset 929 for pykota/trunk/bin
- Timestamp:
- 04/17/03 11:26:21 (22 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/repykota
r927 r929 23 23 # 24 24 # $Log$ 25 # Revision 1.27 2003/04/17 09:26:21 jalet 26 # repykota now reports account balances too. 27 # 25 28 # Revision 1.26 2003/04/16 12:35:49 jalet 26 29 # Groups quota work now ! … … 177 180 print _("Pages grace time: %idays") % self.config.getGraceDelay(printer) 178 181 total = 0 182 totalmoney = 0.0 179 183 if options["groups"] : 180 print _("Group used soft hard grace total")181 print "------------------------------------------------------------ "184 print _("Group used soft hard balance grace total paid") 185 print "------------------------------------------------------------------------------" 182 186 for (ident, name) in self.storage.getPrinterGroups(printerid) : 183 187 quota = self.storage.getGroupPQuota(ident, printerid) 184 total += self.printQuota(name, quota) 188 balance = self.storage.getGroupBalance(ident) 189 limitby = self.storage.getGroupLimitBy(ident) 190 (pages, money) = self.printQuota(name, quota, balance, limitby) 191 total += pages 192 totalmoney += money 185 193 else : 186 194 # default is user quota report 187 print _("User used soft hard grace total")188 print "------------------------------------------------------------ "195 print _("User used soft hard balance grace total paid") 196 print "------------------------------------------------------------------------------" 189 197 for (ident, name) in self.storage.getPrinterUsers(printerid) : 190 198 quota = self.storage.getUserPQuota(ident, printerid) 191 total += self.printQuota(name, quota) 192 if total : 193 print (" " * 43) + (_("Total : %9i") % total) 199 balance = self.storage.getUserBalance(ident) 200 limitby = self.storage.getUserLimitBy(ident) 201 (pages, money) = self.printQuota(name, quota, balance, limitby) 202 total += pages 203 totalmoney += money 204 if total or totalmoney : 205 print (" " * 50) + (_("Total : %9i") % total) + (" %-12.12s" % ("%7.2f" % totalmoney)[:12]) 194 206 printerpagecounter = self.storage.getPrinterPageCounter(printerid) 195 207 try : … … 197 209 except TypeError : 198 210 msg = _("unknown") 199 print (" " * 44) + (_("Real : %s") % msg)211 print (" " * 51) + (_("Real : %s") % msg) 200 212 print 213 if options["groups"] : 214 print _("Totals may be inaccurate if some users are members of several groups.") 201 215 202 def printQuota(self, name, quota ) :216 def printQuota(self, name, quota, balance, limitby) : 203 217 """Prints the quota information.""" 204 218 if quota is not None : … … 208 222 hardlimit = quota["hardlimit"] 209 223 datelimit = quota["datelimit"] 224 if balance is not None : 225 (balance, lifetimepaid) = balance 226 else : 227 (balance, lifetimepaid) = 0.0 210 228 if datelimit is not None : 211 229 now = DateTime.now() … … 215 233 else : 216 234 datelimit = "" 217 reached = ((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-" 218 print "%-10.10s %c %8i %8s %8s %10s %9i" % (name, reached, pagecounter, str(softlimit), str(hardlimit), str(datelimit)[:10], lifepagecounter) 219 return lifepagecounter 235 if limitby == "balance" : 236 reached = (((balance <= 0) and "+") or "-") + "B" 237 else : 238 reached = (((softlimit is not None) and (pagecounter >= softlimit) and "+") or "-") + "Q" 239 strbalance = ("%5.2f" % balance)[:10] 240 strlifetimepaid = ("%6.2f" % lifetimepaid)[:11] 241 print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %-11.11s" % (name, reached, pagecounter, str(softlimit), str(hardlimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) 242 return (lifepagecounter, lifetimepaid) 220 243 221 244