Changeset 3158 for pykota/trunk/bin

Show
Ignore:
Timestamp:
03/30/07 22:59:54 (17 years ago)
Author:
matt
Message:

Allow configuration to avoid printing banner pages for consecutive jobs for the same user on the same printer

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r3153 r3158  
    833833                self.logdebug("Print job cancelled, not printing a banner.", "warn") 
    834834            else : 
    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) 
    836864        self.logdebug("%s banner done." % bannertype.title()) 
    837865