Changeset 2066
- Timestamp:
- 02/16/05 01:29:33 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 9 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2062 r2066 24 24 # 25 25 # $Log$ 26 # Revision 1.89 2005/02/16 00:29:33 jalet 27 # Fixed the maxdenybanners directive. 28 # Introduced the denyduplicates directive. 29 # Fixed some database related glitches. 30 # 26 31 # Revision 1.88 2005/02/14 23:39:50 jalet 27 32 # Introduces the new 'trustjobsize' directive to workaround some printers … … 534 539 self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 535 540 536 # if no data to pass to real backend, probably a filter537 # higher in the chain failed because of a misconfiguration.538 # we deny the job in this case (nothing to print anyway)539 541 if not self.jobSizeBytes : 542 # if no data to pass to real backend, probably a filter 543 # higher in the chain failed because of a misconfiguration. 544 # we deny the job in this case (nothing to print anyway) 540 545 self.printMoreInfo(user, printer, _("Job contains no data. Printing is denied."), "warn") 541 546 action = "DENY" 547 elif self.config.getDenyDuplicates(printer.Name) \ 548 and printer.LastJob.Exists \ 549 and (printer.LastJob.UserName == user.Name) \ 550 and (printer.LastJob.JobMD5Sum == self.checksum) : 551 self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 552 action = "DENY" 542 553 else : 543 554 # checks the user's quota … … 557 568 accountbanner = self.config.getAccountBanner(printer.Name) 558 569 if accountbanner in ["ENDING", "NONE"] : 559 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) :570 if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 560 571 self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 561 572 else : 562 573 if action == 'DENY' : 563 userpquota.warn() # increments the warning counter 574 self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 575 userpquota.incDenyBannerCounter() # increments the warning counter 564 576 self.exportUserInfo(userpquota) 565 577 banner = self.startingBanner(printer.Name) … … 573 585 # handle starting banner pages during accounting 574 586 if accountbanner in ["STARTING", "BOTH"] : 575 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) :587 if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 576 588 self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 577 589 else : 578 590 if action == 'DENY' : 579 userpquota.warn() # increments the warning counter 591 self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 592 userpquota.incDenyBannerCounter() # increments the warning counter 580 593 self.exportUserInfo(userpquota) 581 594 banner = self.startingBanner(printer.Name) … … 604 617 # handle ending banner pages during accounting 605 618 if accountbanner in ["ENDING", "BOTH"] : 606 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) :619 if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 607 620 self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 608 621 else : 609 622 if action == 'DENY' : 610 userpquota.warn() # increments the warning counter 623 self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 624 userpquota.incDenyBannerCounter() # increments the warning counter 611 625 self.exportUserInfo(userpquota) 612 626 banner = self.endingBanner(printer.Name) … … 626 640 self.printMoreInfo(user, printer, _("Job size forced to 0 because printing is denied.")) 627 641 else : 642 userpquota.resetDenyBannerCounter() 628 643 jobsize = self.accounter.getJobSize(printer) 629 644 if self.softwareJobSize and (jobsize != self.softwareJobSize) : … … 664 679 # handle ending banner pages after accounting ends 665 680 if accountbanner in ["STARTING", "NONE"] : 666 if (action == 'DENY') and (userpquota.WarnCount < self.config.getMaxDenyBanners()) :681 if (action == 'DENY') and (userpquota.WarnCount >= self.config.getMaxDenyBanners(printer.Name)) : 667 682 self.printInfo(_("Banner won't be printed : maximum number of deny banners reached."), "warn") 668 683 else : 669 684 if action == 'DENY' : 670 userpquota.warn() # increments the warning counter 685 self.logdebug("Incrementing the number of deny banners for user %s on printer %s" % (user.Name, printer.Name)) 686 userpquota.incDenyBannerCounter() # increments the warning counter 671 687 self.exportUserInfo(userpquota) 672 688 banner = self.endingBanner(printer.Name) -
pykota/trunk/bin/lprngpykota
r2062 r2066 24 24 # 25 25 # $Log$ 26 # Revision 1.17 2005/02/16 00:29:33 jalet 27 # Fixed the maxdenybanners directive. 28 # Introduced the denyduplicates directive. 29 # Fixed some database related glitches. 30 # 26 31 # Revision 1.16 2005/02/14 23:39:50 jalet 27 32 # Introduces the new 'trustjobsize' directive to workaround some printers … … 156 161 self.printMoreInfo(user, printer, _("Job contains no data. Printing is denied."), "warn") 157 162 action = "DENY" 163 elif self.config.getDenyDuplicates(printer.Name) \ 164 and printer.LastJob.Exists \ 165 and (printer.LastJob.UserName == user.Name) \ 166 and (printer.LastJob.JobMD5Sum == self.checksum) : 167 self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 168 action = "DENY" 158 169 else : 159 170 # checks the user's quota -
pykota/trunk/conf/pykota.conf.sample
r2062 r2066 755 755 # SOFTWARE. 756 756 trustjobsize : yes 757 758 # Should we deny duplicate jobs ? 759 # 760 # A duplicate is a job sent twice (or more) in a row to the same printer 761 # by the same user. 762 # 763 # This can be defined either globally or on a per printer basis 764 # The default value is 'no', meaning that duplicate jobs are 765 # allowed. 766 # 767 # NB : if an user prints a job, a second user prints another 768 # job, and the first user prints the first job again, 769 # this is NOT considered as a duplicate since the two 770 # identical jobs printed by the first user are not 771 # one just after the other. 772 # 773 # Possible values are 'yes' and 'no' 774 # 775 denyduplicates : no 776 -
pykota/trunk/NEWS
r2062 r2066 22 22 PyKota NEWS : 23 23 24 - 1.21alpha26 : 25 26 - Fixed the handling of the 'maxdenybanners' directive. 27 28 - Introduced the 'denyduplicates' directive. 29 30 - Fixed some database related glitches. 31 24 32 - 1.21alpha25 : 25 33 -
pykota/trunk/pykota/config.py
r2062 r2066 22 22 # 23 23 # $Log$ 24 # Revision 1.61 2005/02/16 00:29:33 jalet 25 # Fixed the maxdenybanners directive. 26 # Introduced the denyduplicates directive. 27 # Fixed some database related glitches. 28 # 24 29 # Revision 1.60 2005/02/14 23:39:50 jalet 25 30 # Introduces the new 'trustjobsize' directive to workaround some printers … … 604 609 return self.isTrue(self.getGlobalOption("reject_unknown", ignore=1)) 605 610 611 def getDenyDuplicates(self, printername) : 612 """Returns 1 if we want to deny duplicate jobs, else 0.""" 613 try : 614 return self.isTrue(self.getPrinterOption(printername, "denyduplicates")) 615 except PyKotaConfigError : 616 return 0 617 606 618 def getWinbindSeparator(self) : 607 619 """Returns the winbind separator's value if it is set, else None.""" -
pykota/trunk/pykota/storage.py
r2057 r2066 22 22 # 23 23 # $Log$ 24 # Revision 1.70 2005/02/16 00:29:33 jalet 25 # Fixed the maxdenybanners directive. 26 # Introduced the denyduplicates directive. 27 # Fixed some database related glitches. 28 # 24 29 # Revision 1.69 2005/02/13 22:48:37 jalet 25 30 # Added the md5sum to the history … … 487 492 self.WarnCount = 0 488 493 489 def warn(self) :490 """Incre ases the warncounter for this user quota."""494 def incDenyBannerCounter(self) : 495 """Increment the deny banner counter for this user quota.""" 491 496 self.parent.increaseUserPQuotaWarnCount(self) 492 497 self.WarnCount = (self.WarnCount or 0) + 1 498 499 def resetDenyBannerCounter(self) : 500 """Resets the deny banner counter for this user quota.""" 501 self.parent.writeUserPQuotaWarnCount(self, 0) 502 self.WarnCount = 0 493 503 494 504 def reset(self) : -
pykota/trunk/pykota/storages/sql.py
r2057 r2066 22 22 # 23 23 # $Log$ 24 # Revision 1.67 2005/02/16 00:29:33 jalet 25 # Fixed the maxdenybanners directive. 26 # Introduced the denyduplicates directive. 27 # Fixed some database related glitches. 28 # 24 29 # Revision 1.66 2005/02/13 22:48:38 jalet 25 30 # Added the md5sum to the history … … 319 324 userpquota = StorageUserPQuota(self, user, printer) 320 325 if printer.Exists and user.Exists : 321 result = self.doSearch("SELECT id, lifepagecounter, pagecounter, softlimit, hardlimit, datelimitFROM userpquota WHERE userid=%s AND printerid=%s" % (self.doQuote(user.ident), self.doQuote(printer.ident)))326 result = self.doSearch("SELECT * FROM userpquota WHERE userid=%s AND printerid=%s" % (self.doQuote(user.ident), self.doQuote(printer.ident))) 322 327 if result : 323 328 fields = result[0] … … 336 341 grouppquota = StorageGroupPQuota(self, group, printer) 337 342 if group.Exists : 338 result = self.doSearch("SELECT id, softlimit, hardlimit, datelimitFROM grouppquota WHERE groupid=%s AND printerid=%s" % (self.doQuote(group.ident), self.doQuote(printer.ident)))343 result = self.doSearch("SELECT * FROM grouppquota WHERE groupid=%s AND printerid=%s" % (self.doQuote(group.ident), self.doQuote(printer.ident))) 339 344 if result : 340 345 fields = result[0] … … 354 359 """Extracts a printer's last job information.""" 355 360 lastjob = StorageLastJob(self, printer) 356 result = self.doSearch("SELECT jobhistory.id, jobid, userid, username, pagecounter, jobsize, jobprice, filename, title, copies, options, hostname, jobdate FROM jobhistory, users WHERE printerid=%s AND userid=users.id ORDER BY jobdate DESC LIMIT 1" % self.doQuote(printer.ident))361 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)) 357 362 if result : 358 363 fields = result[0] -
pykota/trunk/pykota/version.py
r2062 r2066 22 22 # 23 23 24 __version__ = "1.21alpha2 5_unofficial"24 __version__ = "1.21alpha26_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/TODO
r2063 r2066 38 38 - Web enabled pykotme. 39 39 40 - Uses the MD5 checksum of the job's datas which is now41 saved into the database to be able to forbid duplicate42 jobs.43 44 40 - Maybe put "gracedelay" in the database. 45 41