770 | | elif self.Printer.LastJob.Exists \ |
771 | | and (self.Printer.LastJob.UserName == self.UserName) \ |
772 | | and (self.Printer.LastJob.JobMD5Sum == self.JobMD5Sum) : |
773 | | # TODO : use the current user's last job instead of |
774 | | # TODO : the current printer's last job. This would be |
775 | | # TODO : better but requires an additional database query |
776 | | # TODO : with SQL, and is much more complex with the |
777 | | # TODO : actual LDAP schema. Maybe this is not very |
778 | | # TODO : important, because usually duplicate jobs are sucessive. |
779 | | msg = _("Job is a dupe") |
780 | | if denyduplicates == 1 : |
781 | | self.printInfo("%s : %s." % (msg, _("Printing is denied by configuration")), "warn") |
782 | | self.Action = "DENY" |
783 | | self.Reason = _("Duplicate print jobs are not allowed on printer %s.") % self.PrinterName |
784 | | else : |
785 | | self.logdebug("Launching subprocess [%s] to see if duplicate jobs should be allowed or not." % denyduplicates) |
786 | | fanswer = os.popen(denyduplicates, "r") |
787 | | self.Action = fanswer.read().strip().upper() |
788 | | fanswer.close() |
789 | | if self.Action == "DENY" : |
790 | | self.printInfo("%s : %s." % (msg, _("Subprocess denied printing of a dupe")), "warn") |
791 | | self.Reason = _("Duplicate print jobs are not allowed on printer %s at this time.") % self.PrinterName |
792 | | else : |
793 | | self.printInfo("%s : %s." % (msg, _("Subprocess allowed printing of a dupe")), "warn") |
794 | | else : |
795 | | self.logdebug("Job doesn't seem to be a duplicate.") |
| 772 | else : |
| 773 | if self.Printer.LastJob.Exists \ |
| 774 | and (self.Printer.LastJob.UserName == self.UserName) \ |
| 775 | and (self.Printer.LastJob.JobMD5Sum == self.JobMD5Sum) : |
| 776 | now = DateTime.now() |
| 777 | try : |
| 778 | previous = DateTime.ISO.ParseDateTime(self.Printer.LastJob.JobDate).localtime() |
| 779 | except : |
| 780 | previous = now |
| 781 | difference = (now - previous).seconds |
| 782 | duplicatesdelay = self.config.getDuplicatesDelay(self.PrinterName) |
| 783 | self.logdebug("Difference with previous job : %.2f seconds. Duplicates delay : %.2f seconds." % (difference, duplicatesdelay)) |
| 784 | if difference > duplicatesdelay : |
| 785 | self.logdebug("Duplicate job allowed because previous one is more than %.2f seconds old." % duplicatesdelay) |
| 786 | else : |
| 787 | # TODO : use the current user's last job instead of |
| 788 | # TODO : the current printer's last job. This would be |
| 789 | # TODO : better but requires an additional database query |
| 790 | # TODO : with SQL, and is much more complex with the |
| 791 | # TODO : actual LDAP schema. Maybe this is not very |
| 792 | # TODO : important, because usually duplicate jobs are sucessive. |
| 793 | msg = _("Job is a dupe") |
| 794 | if denyduplicates == 1 : |
| 795 | self.printInfo("%s : %s." % (msg, _("Printing is denied by configuration")), "warn") |
| 796 | self.Action = "DENY" |
| 797 | self.Reason = _("Duplicate print jobs are not allowed on printer %s.") % self.PrinterName |
| 798 | else : |
| 799 | self.logdebug("Launching subprocess [%s] to see if duplicate jobs should be allowed or not." % denyduplicates) |
| 800 | fanswer = os.popen(denyduplicates, "r") |
| 801 | self.Action = fanswer.read().strip().upper() |
| 802 | fanswer.close() |
| 803 | if self.Action == "DENY" : |
| 804 | self.printInfo("%s : %s." % (msg, _("Subprocess denied printing of a dupe")), "warn") |
| 805 | self.Reason = _("Duplicate print jobs are not allowed on printer %s at this time.") % self.PrinterName |
| 806 | else : |
| 807 | self.printInfo("%s : %s." % (msg, _("Subprocess allowed printing of a dupe")), "warn") |
| 808 | else : |
| 809 | self.logdebug("Job doesn't seem to be a duplicate.") |