Changeset 2455

Show
Ignore:
Timestamp:
09/17/05 23:00:45 (19 years ago)
Author:
jerome
Message:

Added the precomputed job's size and price to the history.

Location:
pykota/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2452 r2455  
    933933                                    self.Action, self.JobSize, self.JobPrice, self.InputFile, \ 
    934934                                    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) 
    936937            self.printInfo(_("Job added to history.")) 
    937938             
  • pykota/trunk/cgi-bin/printquota.cgi

    r2344 r2455  
    215215                               _("PageCounter"), _("Title"), _("Filename"), \ 
    216216                               _("Options"), _("MD5Sum"), _("BillingCode"), \ 
    217                                _("Pages")] 
     217                               _("PrecomputedJobSize"), _("PrecomputedJobPrice"), _("Pages")] 
    218218                    self.report.append('<tr class="pykotacolsheader">%s</tr>' % "".join(["<th>%s</th>" % h for h in headers])) 
    219219                    oddeven = 0 
     
    257257                                                            job.JobMD5Sum, \ 
    258258                                                            billingcode_url, \ 
     259                                                            job.PrecomputedJobSize, \ 
     260                                                            job.PrecomputedJobPrice, \ 
    259261                                                            job.JobPages)]))) 
    260262                    self.report.append('</table>') 
  • pykota/trunk/NEWS

    r2454 r2455  
    4343          to increase or decrease page limits. 
    4444           
     45        - Added the precomputed job's size and price to the history 
     46          for controlling purpose. 
     47         
    4548    - 1.23alpha29 : 
    4649     
  • pykota/trunk/pykota/storage.py

    r2452 r2455  
    149149        self.PricePerJob = None 
    150150        self.Description = None 
     151        self.MaxJobSize = None 
    151152        self.Coefficients = None 
    152153         
     
    159160            raise AttributeError, name 
    160161             
    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) : 
    162163        """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) 
    164165        # TODO : update LastJob object ? Probably not needed. 
    165166         
     
    226227        self.DateLimit = None 
    227228        self.WarnCount = None 
     229        self.MaxJobSize = None 
    228230         
    229231    def __getattr__(self, name) :     
     
    331333        self.HardLimit = None 
    332334        self.DateLimit = None 
     335        self.MaxJobSize = None 
    333336         
    334337    def __getattr__(self, name) :     
     
    411414        self.JobPages = None 
    412415        self.JobBillingCode = None 
     416        self.PrecomputedJobSize = None 
     417        self.PrecomputedJobPrice = None 
    413418         
    414419    def __getattr__(self, name) :     
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2452 r2455  
    535535                                                                  "pykotaPages",  
    536536                                                                  "pykotaMD5Sum",  
     537                                                                  "pykotaPrecomputedJobSize", 
     538                                                                  "pykotaPrecomputedJobPrice", 
    537539                                                                  "createTimestamp" ],  
    538540                                                                base="cn=%s,%s" % (lastjobident, self.info["jobbase"]), scope=ldap.SCOPE_BASE) 
     
    563565                lastjob.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
    564566                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 
    565575                if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == "hidden" : 
    566576                    (lastjob.JobTitle, lastjob.JobFileName, lastjob.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
     
    961971        self.doModify(lastjob.ident, fields)          
    962972         
    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) : 
    964974        """Adds a job in a printer's history.""" 
    965975        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
     
    989999                   "pykotaPages" : jobpages,            # don't add this attribute if it is not set, so no string conversion 
    9901000                   "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), 
    9911003                 } 
    9921004        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
     
    11021114                                               "pykotaPages",  
    11031115                                               "pykotaMD5Sum",  
     1116                                               "pykotaPrecomputedJobSize", 
     1117                                               "pykotaPrecomputedJobPrice", 
    11041118                                               "createTimestamp" ],  
    11051119                                      base=self.info["jobbase"]) 
     
    11281142                job.JobMD5Sum = fields.get("pykotaMD5Sum", [None])[0] 
    11291143                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 
    11301152                if job.JobTitle == job.JobFileName == job.JobOptions == "hidden" : 
    11311153                    (job.JobTitle, job.JobFileName, job.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
     
    13841406        entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None, start=startdate, end=enddate) 
    13851407        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") ]  
    13871409            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))  
    13891411            return result 
    13901412             
  • pykota/trunk/pykota/storages/sql.py

    r2452 r2455  
    271271        """Extracts a printer's last job information.""" 
    272272        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)) 
    274274        if result : 
    275275            fields = result[0] 
     
    291291            lastjob.JobPages = fields.get("pages") 
    292292            lastjob.JobBillingCode = self.databaseToUserCharset(fields.get("billingcode")) 
     293            lastjob.PrecomputedJobSize = fields.get("precomputedjobsize") 
     294            lastjob.PrecomputedJobPrice = fields.get("precomputedjobprice") 
    293295            if lastjob.JobTitle == lastjob.JobFileName == lastjob.JobOptions == "hidden" : 
    294296                (lastjob.JobTitle, lastjob.JobFileName, lastjob.JobOptions) = (_("Hidden because of privacy concerns"),) * 3 
     
    522524        self.doModify("UPDATE jobhistory SET jobsize=%s, jobprice=%s WHERE id=%s" % (self.doQuote(jobsize), self.doQuote(jobprice), self.doQuote(lastjob.ident))) 
    523525         
    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) : 
    525527        """Adds a job in a printer's history.""" 
    526528        if self.privacy :     
     
    533535        if (not self.disablehistory) or (not printer.LastJob.Exists) : 
    534536            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))) 
    536538            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))) 
    538540        else :         
    539541            # 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))) 
    541543             
    542544    def writeUserPQuotaLimits(self, userpquota, softlimit, hardlimit) : 
     
    612614                job.JobPages = fields.get("pages") 
    613615                job.JobBillingCode = self.databaseToUserCharset(fields.get("billingcode") or "") 
     616                job.PrecomputedJobSize = fields.get("precomputedjobsize") 
     617                job.PrecomputedJobPrice = fields.get("precomputedjobprice") 
    614618                job.UserName = fields.get("username") 
    615619                job.PrinterName = fields.get("printername")