Changeset 1048
- Timestamp:
- 06/30/03 14:46:15 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 4 added
- 4 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/repykota
r1041 r1048 23 23 # 24 24 # $Log$ 25 # Revision 1.40 2003/06/30 12:46:15 jalet 26 # Extracted reporting code. 27 # 25 28 # Revision 1.39 2003/06/25 14:10:01 jalet 26 29 # Hey, it may work (edpykota --reset excepted) ! … … 160 163 from pykota.config import PyKotaConfigError 161 164 from pykota.storage import PyKotaStorageError 165 from pykota.reporter import PyKotaReporterError 166 from pykota import reporter 162 167 163 168 __doc__ = """repykota v%s (C) 2003 C@LL - Conseil Internet & Logiciels Libres … … 241 246 if not printers : 242 247 raise PyKotaToolError, _("There's no printer matching %s") % options["printer"] 243 for printer in printers :244 print _("*** Report for %s quota on printer %s") % ((options["groups"] and "group") or "user", printer.Name)245 print _("Pages grace time: %i days") % self.config.getGraceDelay(printer.Name)246 if printer.PricePerJob is not None :247 print _("Price per job: %.3f") % printer.PricePerJob248 if printer.PricePerPage is not None :249 print _("Price per page: %.3f") % printer.PricePerPage250 total = 0251 totalmoney = 0.0252 if options["groups"] :253 print _("Group used soft hard balance grace total paid")254 print "------------------------------------------------------------------------------"255 for (group, grouppquota) in self.storage.getPrinterGroupsAndQuotas(printer, ugnames) :256 (pages, money) = self.printQuota(group, grouppquota)257 total += pages258 totalmoney += money259 else :260 # default is user quota report261 print _("User used soft hard balance grace total paid")262 print "------------------------------------------------------------------------------"263 for (user, userpquota) in self.storage.getPrinterUsersAndQuotas(printer, ugnames) :264 (pages, money) = self.printQuota(user, userpquota)265 total += pages266 totalmoney += money267 if total or totalmoney :268 print (" " * 50) + (_("Total : %9i") % total) + ("%11s" % ("%7.2f" % totalmoney)[:11])269 try :270 msg = "%9i" % printer.LastJob.PrinterPageCounter271 except TypeError :272 msg = _("unknown")273 print (" " * 51) + (_("Real : %s") % msg)274 print275 if options["groups"] :276 print _("Totals may be inaccurate if some users are members of several groups.")277 278 def printQuota(self, entry, quota) :279 """Prints the quota information."""280 lifepagecounter = int(quota.LifePageCounter or 0)281 pagecounter = int(quota.PageCounter or 0)282 balance = float(entry.AccountBalance or 0.0)283 lifetimepaid = float(entry.LifeTimePaid or 0.0)284 285 if quota.DateLimit is not None :286 now = DateTime.now()287 datelimit = DateTime.ISO.ParseDateTime(quota.DateLimit)288 if now >= datelimit :289 datelimit = "DENY"290 elif (quota.HardLimit is not None) and (pagecounter >= quota.HardLimit) :291 datelimit = "DENY"292 elif (quota.HardLimit is None) and (quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) :293 datelimit = "DENY"294 else :295 datelimit = ""296 248 297 if entry.LimitBy.lower() == "balance" : 298 reached = (((balance <= 0) and "+") or "-") + "B" 299 else : 300 reached = (((quota.SoftLimit is not None) and (pagecounter >= quota.SoftLimit) and "+") or "-") + "Q" 301 302 strbalance = ("%5.2f" % balance)[:10] 303 strlifetimepaid = ("%6.2f" % lifetimepaid)[:10] 304 print "%-9.9s %s %7i %7s %7s %10s %-10.10s %8i %10s" % (entry.Name, reached, pagecounter, str(quota.SoftLimit), str(quota.HardLimit), strbalance, str(datelimit)[:10], lifepagecounter, strlifetimepaid) 305 return (lifepagecounter, lifetimepaid) 249 self.reportingtool = reporter.openReporter(self, "text", printers, ugnames, (options["groups"] and 1) or 0) 250 print self.reportingtool.generateReport() 306 251 307 252 if __name__ == "__main__" : … … 314 259 315 260 # Initializes the command line tool 316 report er= RePyKota(doc=__doc__)261 reportTool = RePyKota(doc=__doc__) 317 262 318 263 # parse and checks the command line 319 (options, args) = report er.parseCommandline(sys.argv[1:], short_options, long_options, allownothing=1)264 (options, args) = reportTool.parseCommandline(sys.argv[1:], short_options, long_options, allownothing=1) 320 265 321 266 # sets long options … … 327 272 328 273 if options["help"] : 329 report er.display_usage_and_quit()274 reportTool.display_usage_and_quit() 330 275 elif options["version"] : 331 report er.display_version_and_quit()276 reportTool.display_version_and_quit() 332 277 elif options["users"] and options["groups"] : 333 278 raise PyKotaToolError, _("incompatible options, see help.") 334 279 else : 335 sys.exit(report er.main(args, options))336 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError ), msg :280 sys.exit(reportTool.main(args, options)) 281 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaReporterError), msg : 337 282 sys.stderr.write("%s\n" % msg) 338 283 sys.stderr.flush() -
pykota/trunk/cgi-bin/printquota.cgi
r952 r1048 23 23 # 24 24 # $Log$ 25 # Revision 1.7 2003/06/30 12:46:15 jalet 26 # Extracted reporting code. 27 # 25 28 # Revision 1.6 2003/04/23 22:13:56 jalet 26 29 # Preliminary support for LPRng added BUT STILL UNTESTED. … … 48 51 import os 49 52 import cgi 53 54 from pykota import version 55 from pykota.tool import PyKotaTool, PyKotaToolError 56 from pykota.config import PyKotaConfigError 57 from pykota.storage import PyKotaStorageError 50 58 51 59 header = """Content-type: text/html -
pykota/trunk/pykota/tool.py
r1041 r1048 21 21 # 22 22 # $Log$ 23 # Revision 1.42 2003/06/30 12:46:15 jalet 24 # Extracted reporting code. 25 # 23 26 # Revision 1.41 2003/06/25 14:10:01 jalet 24 27 # Hey, it may work (edpykota --reset excepted) ! … … 498 501 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 499 502 return action 500 -
pykota/trunk/setup.py
r1018 r1048 23 23 # 24 24 # $Log$ 25 # Revision 1.17 2003/06/30 12:46:15 jalet 26 # Extracted reporting code. 27 # 25 28 # Revision 1.16 2003/06/06 20:49:15 jalet 26 29 # Very latest schema. UNTESTED. … … 228 231 author_email = "alet@librelogiciel.com", 229 232 url = "http://www.librelogiciel.com/software/", 230 packages = [ "pykota", "pykota.storages", "pykota.requesters", "pykota.loggers", "pykota.accounters" ],233 packages = [ "pykota", "pykota.storages", "pykota.requesters", "pykota.loggers", "pykota.accounters", "pykota.reporters" ], 231 234 scripts = [ "bin/pykota", "bin/edpykota", "bin/repykota", "bin/warnpykota" ], 232 235 data_files = data_files)