835 | | getattr(self, "%sBanner" % bannertype)(withaccounting) |
| 835 | self.logdebug("Checking if job owner printed the last job and if another banner is needed...") |
| 836 | # Print the banner by default |
| 837 | printbanner = True |
| 838 | avoidduplicatebanners = self.config.getAvoidDuplicateBanners(self.PrinterName) |
| 839 | if ((avoidduplicatebanners == "NO") or (avoidduplicatebanners == 0)): |
| 840 | self.logdebug("We want all banners to be printed.") |
| 841 | else : |
| 842 | # Check if we should deny the banner or not |
| 843 | if self.Printer.LastJob.Exists \ |
| 844 | and (self.Printer.LastJob.UserName == self.UserName) : |
| 845 | if (avoidduplicatebanners == "YES") : |
| 846 | printbanner = False |
| 847 | else : |
| 848 | # avoidduplicatebanners is an integer, since NO, |
| 849 | # YES and 0 are already handled |
| 850 | now = DateTime.now() |
| 851 | try : |
| 852 | previous = DateTime.ISO.ParseDateTime(str(self.Printer.LastJob.JobDate)[:19]).localtime() |
| 853 | except : |
| 854 | previous = now |
| 855 | difference = (now - previous).seconds |
| 856 | self.logdebug("Difference with previous job : %.2f seconds. Try to avoid banners for : %.2f seconds." % (difference, avoidduplicatebanners)) |
| 857 | if difference < avoidduplicatebanners : |
| 858 | self.logdebug("Duplicate banner avoided because previous banner is less than %.2f seconds old." % avoidduplicatebanners) |
| 859 | printbanner = False |
| 860 | else : |
| 861 | printbanner = True |
| 862 | if printbanner : |
| 863 | getattr(self, "%sBanner" % bannertype)(withaccounting) |