Changeset 2455
- Timestamp:
- 09/17/05 23:00:45 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2452 r2455 933 933 self.Action, self.JobSize, self.JobPrice, self.InputFile, \ 934 934 self.Title, self.Copies, self.Options, self.ClientHost, \ 935 self.JobSizeBytes, self.JobMD5Sum, None, self.JobBillingCode) 935 self.JobSizeBytes, self.JobMD5Sum, None, self.JobBillingCode, \ 936 self.softwareJobSize, self.softwareJobPrice) 936 937 self.printInfo(_("Job added to history.")) 937 938 -
pykota/trunk/cgi-bin/printquota.cgi
r2344 r2455 215 215 _("PageCounter"), _("Title"), _("Filename"), \ 216 216 _("Options"), _("MD5Sum"), _("BillingCode"), \ 217 _("P ages")]217 _("PrecomputedJobSize"), _("PrecomputedJobPrice"), _("Pages")] 218 218 self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 219 219 oddeven = 0 … … 257 257 job.JobMD5Sum, \ 258 258 billingcode_url, \ 259 job.PrecomputedJobSize, \ 260 job.PrecomputedJobPrice, \ 259 261 job.JobPages)]))) 260 262 self.report.append('</table>') -
pykota/trunk/NEWS
r2454 r2455 43 43 to increase or decrease page limits. 44 44 45 - Added the precomputed job's size and price to the history 46 for controlling purpose. 47 45 48 - 1.23alpha29 : 46 49 -
pykota/trunk/pykota/storage.py
r2452 r2455 149 149 self.PricePerJob = None 150 150 self.Description = None 151 self.MaxJobSize = None 151 152 self.Coefficients = None 152 153 … … 159 160 raise AttributeError, name 160 161 161 def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None ) :162 def addJobToHistory(self, jobid, user, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None, precomputedsize=None, precomputedprice=None) : 162 163 """Adds a job to the printer's history.""" 163 self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, clienthost, jobsizebytes, jobmd5sum, jobpages, jobbilling )164 self.parent.writeJobNew(self, user, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, clienthost, jobsizebytes, jobmd5sum, jobpages, jobbilling, precomputedsize, precomputedprice) 164 165 # TODO : update LastJob object ? Probably not needed. 165 166 … … 226 227 self.DateLimit = None 227 228 self.WarnCount = None 229 self.MaxJobSize = None 228 230 229 231 def __getattr__(self, name) : … … 331 333 self.HardLimit = None 332 334 self.DateLimit = None 335 self.MaxJobSize = None 333 336 334 337 def __getattr__(self, name) : … … 411 414 self.JobPages = None 412 415 self.JobBillingCode = None 416 self.PrecomputedJobSize = None 417 self.PrecomputedJobPrice = None 413 418 414 419 def __getattr__(self, name) : -
pykota/trunk/pykota/storages/ldapstorage.py
r2452 r2455 535 535 "pykotaPages", 536 536 "pykotaMD5Sum", 537 "pykotaPrecomputedJobSize", 538 "pykotaPrecomputedJobPrice", 537 539 "createTimestamp" ], 538 540 base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) … … 563 565 lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 564 566 lastjob.JobPages = fields.get("pykotaPages", [""])[0] 567 try : 568 lastjob.PrecomputedJobSize = int(fields.get("pykotaPrecomputedJobSize", [0])[0]) 569 except ValueError : 570 lastjob.PrecomputedJobSize = None 571 try : 572 lastjob.PrecomputedJobPrice = float(fields.get("pykotaPrecomputedJobPrice", [0.0])[0]) 573 except ValueError : 574 lastjob.PrecomputedJobPrice = None 565 575 if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == "hidden" : 566 576 (lastjob.JobTitle, lastjob.JobFileName, lastjob.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 … … 961 971 self.doModify(lastjob.ident, fields) 962 972 963 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None ) :973 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None, precomputedsize=None, precomputedprice=None) : 964 974 """Adds a job in a printer's history.""" 965 975 if (not self.disablehistory) or (not printer.LastJob.Exists) : … … 989 999 "pykotaPages" : jobpages, # don't add this attribute if it is not set, so no string conversion 990 1000 "pykotaBillingCode" : self.userCharsetToDatabase(jobbilling), # don't add this attribute if it is not set, so no string conversion 1001 "pykotaPrecomputedJobSize" : str(precomputedsize), 1002 "pykotaPrecomputedPrice" : str(precomputedprice), 991 1003 } 992 1004 if (not self.disablehistory) or (not printer.LastJob.Exists) : … … 1102 1114 "pykotaPages", 1103 1115 "pykotaMD5Sum", 1116 "pykotaPrecomputedJobSize", 1117 "pykotaPrecomputedJobPrice", 1104 1118 "createTimestamp" ], 1105 1119 base=self.info["jobbase"]) … … 1128 1142 job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 1129 1143 job.JobPages = fields.get("pykotaPages", [""])[0] 1144 try : 1145 job.PrecomputedJobSize = int(fields.get("pykotaPrecomputedJobSize", [0])[0]) 1146 except ValueError : 1147 job.PrecomputedJobSize = None 1148 try : 1149 job.PrecomputedJobPrice = float(fields.get("pykotaPrecomputedJobPrice", [0.0])[0]) 1150 except ValueError : 1151 job.PrecomputedJobPrice = None 1130 1152 if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" : 1131 1153 (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 … … 1384 1406 entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None, start=startdate, end=enddate) 1385 1407 if entries : 1386 result = [ ("username", "printername", "dn", "jobid", "pagecounter", "jobsize", "action", "jobdate", "filename", "title", "copies", "options", "jobprice", "hostname", "jobsizebytes", "md5sum", "pages", "billingcode" ) ]1408 result = [ ("username", "printername", "dn", "jobid", "pagecounter", "jobsize", "action", "jobdate", "filename", "title", "copies", "options", "jobprice", "hostname", "jobsizebytes", "md5sum", "pages", "billingcode", "precomputedjobsize", "precomputedjobprice") ] 1387 1409 for entry in entries : 1388 result.append((entry.UserName, entry.PrinterName, entry.ident, entry.JobId, entry.PrinterPageCounter, entry.JobSize, entry.JobAction, entry.JobDate, entry.JobFileName, entry.JobTitle, entry.JobCopies, entry.JobOptions, entry.JobPrice, entry.JobHostName, entry.JobSizeBytes, entry.JobMD5Sum, entry.JobPages, entry.JobBillingCode ))1410 result.append((entry.UserName, entry.PrinterName, entry.ident, entry.JobId, entry.PrinterPageCounter, entry.JobSize, entry.JobAction, entry.JobDate, entry.JobFileName, entry.JobTitle, entry.JobCopies, entry.JobOptions, entry.JobPrice, entry.JobHostName, entry.JobSizeBytes, entry.JobMD5Sum, entry.JobPages, entry.JobBillingCode, entry.PrecomputedJobSize, entry.PrecomputedJobPrice)) 1389 1411 return result 1390 1412 -
pykota/trunk/pykota/storages/sql.py
r2452 r2455 271 271 """Extracts a printer's last job information.""" 272 272 lastjob = StorageLastJob(self, printer) 273 result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, hostname, jobdate, md5sum, pages, billingcode FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))273 result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, hostname, jobdate, md5sum, pages, billingcode, precomputedjobsize, precomputedjobprice FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident)) 274 274 if result : 275 275 fields = result[0] … … 291 291 lastjob.JobPages = fields.get("pages") 292 292 lastjob.JobBillingCode = self.databaseToUserCharset(fields.get("billingcode")) 293 lastjob.PrecomputedJobSize = fields.get("precomputedjobsize") 294 lastjob.PrecomputedJobPrice = fields.get("precomputedjobprice") 293 295 if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == "hidden" : 294 296 (lastjob.JobTitle, lastjob.JobFileName, lastjob.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 … … 522 524 self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident))) 523 525 524 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None ) :526 def writeJobNew(self, printer, user, jobid, pagecounter, action, jobsize=None, jobprice=None, filename=None, title=None, copies=None, options=None, clienthost=None, jobsizebytes=None, jobmd5sum=None, jobpages=None, jobbilling=None, precomputedsize=None, precomputedprice=None) : 525 527 """Adds a job in a printer's history.""" 526 528 if self.privacy : … … 533 535 if (not self.disablehistory) or (not printer.LastJob.Exists) : 534 536 if jobsize is not None : 535 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname, jobsizebytes, md5sum, pages, billingcode ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling)))537 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, jobsize, jobprice, filename, title, copies, options, hostname, jobsizebytes, md5sum, pages, billingcode, precomputedjobsize, precomputedjobprice) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(precomputedsize), self.doQuote(precomputedprice))) 536 538 else : 537 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname, jobsizebytes, md5sum, pages, billingcode ) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling)))539 self.doModify("INSERT INTO jobhistory (userid, printerid, jobid, pagecounter, action, filename, title, copies, options, hostname, jobsizebytes, md5sum, pages, billingcode, precomputedjobsize, precomputedjobprice) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)" % (self.doQuote(user.ident), self.doQuote(printer.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(precomputedsize), self.doQuote(precomputedprice))) 538 540 else : 539 541 # here we explicitly want to reset jobsize to NULL if needed 540 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, hostname=%s, jobsizebytes=%s, md5sum=%s, pages=%s, billingcode=%s, jobdate=now() WHERE id=%s" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(printer.LastJob.ident)))542 self.doModify("UPDATE jobhistory SET userid=%s, jobid=%s, pagecounter=%s, action=%s, jobsize=%s, jobprice=%s, filename=%s, title=%s, copies=%s, options=%s, hostname=%s, jobsizebytes=%s, md5sum=%s, pages=%s, billingcode=%s, precomputedjobsize=%s, precomputedjobprice=%s, jobdate=now() WHERE id=%s" % (self.doQuote(user.ident), self.doQuote(jobid), self.doQuote(pagecounter), self.doQuote(action), self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(filename), self.doQuote(title), self.doQuote(copies), self.doQuote(options), self.doQuote(clienthost), self.doQuote(jobsizebytes), self.doQuote(jobmd5sum), self.doQuote(jobpages), self.doQuote(jobbilling), self.doQuote(precomputedsize), self.doQuote(precomputedprice), self.doQuote(printer.LastJob.ident))) 541 543 542 544 def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : … … 612 614 job.JobPages = fields.get("pages") 613 615 job.JobBillingCode = self.databaseToUserCharset(fields.get("billingcode") or "") 616 job.PrecomputedJobSize = fields.get("precomputedjobsize") 617 job.PrecomputedJobPrice = fields.get("precomputedjobprice") 614 618 job.UserName = fields.get("username") 615 619 job.PrinterName = fields.get("printername")