Changeset 3036
- Timestamp:
- 10/13/06 23:51:14 (18 years ago)
- Location:
- pykota/trunk
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r3023 r3036 574 574 """Precomputes the job price with a software method.""" 575 575 self.logdebug("Precomputing job's price...") 576 self.softwareJobPrice = self.UserPQuota.computeJobPrice(self.softwareJobSize )576 self.softwareJobPrice = self.UserPQuota.computeJobPrice(self.softwareJobSize, self.preaccounter.inkUsage) 577 577 self.logdebug("Precomputed job's price is %.3f credits." \ 578 578 % self.softwareJobPrice) … … 1270 1270 # update the quota for the current user on this printer 1271 1271 self.printInfo(_("Updating user %s's quota on printer %s") % (self.UserName, self.PrinterName)) 1272 self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize )1272 self.JobPrice = self.UserPQuota.increasePagesUsage(self.JobSize, self.accounter.inkUsage) 1273 1273 1274 1274 # adds the current job to history -
pykota/trunk/conf/pykota.conf.sample
r3025 r3036 597 597 # Software accounting unfortunately may overcharge users in case of paper 598 598 # jams. 599 # 600 # Ink computes the price of a print job by parsing the job's datas 601 # through pkpgcounter, and using the percents of ink coverage returned 602 # for each color in the specified colorspace. 603 604 # Supported colorspaces for ink accounting currently are : 605 # 606 # bw ===> Black & White 607 # cmyk ===> Cyan, Magenta, Yellow, Black 608 # cmy ===> Cyan, Magenta, Yellow 609 # rgb ===> Red, Green, Blue 610 # 611 # Supported resolutions for ink accounting are any number of dots 612 # per inch comprised between 72 and 1200. 613 # IMPORTANT : increasing the resolution increases precision, but 614 # increase CPU load a lot at the same time. The default resolution 615 # if unset is 72, for 72 dpi. 599 616 # 600 617 # You can get hints on which configuration is best for your printers by … … 619 636 # accounter : software(/usr/bin/pkpgcounter) 620 637 # accounter : software() 638 # accounter : ink(cmyk, 150) 639 # accounter : ink(bw, 300) 640 # accounter : ink(bw) 641 # accounter : ink(cmy, 72) 621 642 # 622 643 # This directive can be set either globally or per printer or both. … … 648 669 # preaccounter: software() 649 670 # preaccounter: software(/path/to/your/script) 671 # preaccounter: ink(colorspace, resolution) 650 672 # 651 673 # NB : the preaccounter directive doesn't support hardware() for obvious … … 657 679 # in the case your printer supports an hardware accounter but pkpgcounter 658 680 # can't parse your printer driver's datas. 681 # 682 # Supported colorspaces for ink accounting currently are : 683 # 684 # bw ===> Black & White 685 # cmyk ===> Cyan, Magenta, Yellow, Black 686 # cmy ===> Cyan, Magenta, Yellow 687 # rgb ===> Red, Green, Blue 688 # 689 # Supported resolutions for ink accounting are any number of dots 690 # per inch comprised between 72 and 1200. 691 # IMPORTANT : increasing the resolution increases precision, but 692 # increase CPU load a lot at the same time. The default resolution 693 # if unset is 72, for 72 dpi. 659 694 # 660 695 # This value can be set either globally or on a per printer basis -
pykota/trunk/NEWS
r3032 r3036 22 22 PyKota NEWS : 23 23 24 - 1.25alpha14 (2006-10-13) : 25 26 - First useable release with the computation of ink 27 usage, through the introduction of the 'ink(cspace, resolution)' 28 value for the 'preaccounter' and 'accounter' directives in 29 pykota.conf 30 24 31 - 1.25alpha13 (2006-10-04) : 25 32 -
pykota/trunk/pykota/accounter.py
r3000 r3036 45 45 self.isSoftware = 1 # by default software accounting 46 46 self.isPreAccounter = ispreaccounter 47 self.inkUsage = [] 47 48 48 49 def getLastPageCounter(self) : -
pykota/trunk/pykota/accounters/ink.py
r3034 r3036 42 42 # know the result. 43 43 self.filter.logdebug("Precomputing pass told us that job is %s pages long." % self.filter.softwareJobSize) 44 return self.filter.softwareJobSize # Optimize : already computed ! 44 self.inkUsage = self.filter.preaccounter.inkUsage # Optimize : already computed ! 45 return self.filter.softwareJobSize # Optimize : already computed ! 45 46 46 (colorspace, resolution) = [p.strip() for p in self.arguments.split(',')] 47 parameters = [p.strip() for p in self.arguments.split(',')] 48 if len(parameters) == 1 : 49 parameters.append("72") 50 (colorspace, resolution) = parameters 47 51 colorspace = colorspace.lower() 48 52 if colorspace not in ("cmyk", "bw", "cmy", "rgb") : … … 57 61 58 62 jobsize = 0 59 self.inkUsage = []60 63 if self.filter.JobSizeBytes : 61 64 try : -
pykota/trunk/pykota/storage.py
r3033 r3036 308 308 self.isDirty = True 309 309 310 def computeJobPrice(self, jobsize ) :310 def computeJobPrice(self, jobsize, inkusage=[]) : 311 311 """Computes the job price as the sum of all parent printers' prices + current printer's ones.""" 312 312 totalprice = 0.0 … … 314 314 if self.User.OverCharge != 0.0 : # optimization, but TODO : beware of rounding errors 315 315 for upq in [ self ] + self.ParentPrintersUserPQuota : 316 price = (float(upq.Printer.PricePerPage or 0.0) * jobsize) + float(upq.Printer.PricePerJob or 0.0) 317 totalprice += price 316 totalprice += float(upq.Printer.PricePerJob or 0.0) 317 pageprice = float(upq.Printer.PricePerPage or 0.0) 318 if not inkusage : 319 totalprice += (jobsize * pageprice) 320 else : 321 for pageindex in range(jobsize) : 322 try : 323 usage = inkusage[pageindex] 324 except IndexError : 325 self.parent.tool.logdebug("No ink usage information. Using base cost of %f credits for page %i." % (pageprice, pageindex+1)) 326 totalprice += pageprice 327 else : 328 coefficients = self.Printer.Coefficients 329 for (ink, value) in usage.items() : 330 coefvalue = coefficients.get(ink, 1.0) 331 coefprice = (coefvalue * pageprice) / 100.0 332 inkprice = coefprice * value 333 self.parent.tool.logdebug("Applying coefficient %f for color %s (used at %f%% on page %i) to base cost %f gives %f" % (coefvalue, ink, value, pageindex+1, pageprice, inkprice)) 334 totalprice += coefprice 318 335 if self.User.OverCharge != 1.0 : # TODO : beware of rounding errors 319 336 overcharged = totalprice * self.User.OverCharge 320 self.parent.tool.logdebug("Overcharging %s by a factor of %s ===> User %s will be charged for %s units." % (totalprice, self.User.OverCharge, self.User.Name, overcharged))337 self.parent.tool.logdebug("Overcharging %s by a factor of %s ===> User %s will be charged for %s credits." % (totalprice, self.User.OverCharge, self.User.Name, overcharged)) 321 338 return overcharged 322 339 else : 323 340 return totalprice 324 341 325 def increasePagesUsage(self, jobsize ) :342 def increasePagesUsage(self, jobsize, inkusage=[]) : 326 343 """Increase the value of used pages and money.""" 327 jobprice = self.computeJobPrice(jobsize )344 jobprice = self.computeJobPrice(jobsize, inkusage) 328 345 if jobsize : 329 346 if jobprice : -
pykota/trunk/pykota/version.py
r3025 r3036 22 22 # 23 23 24 __version__ = "1.25alpha1 3_unofficial"24 __version__ = "1.25alpha14_unofficial" 25 25 26 26 __doc__ = "PyKota : a complete Printing Quota Solution for CUPS." -
pykota/trunk/README
r3015 r3036 119 119 - Price per page and per job can be set differently 120 120 on any printer. 121 122 - Price depending on ink/toner usage is supported 123 with many printer drivers. 121 124 122 125 - Low level of page quota or account balance are -
pykota/trunk/TODO
r3033 r3036 59 59 files at run time. 60 60 61 - Ink accounting ala PrintBill.62 63 61 - Price and statistics per page format. 64 62