Show
Ignore:
Timestamp:
06/10/05 22:39:13 (19 years ago)
Author:
jerome
Message:

Extended syntax for the denyduplicates directive : it now
allows any external command to be launched, which will decide
if the dupes should be allowed or not.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2303 r2308  
    239239            self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
    240240             
     241            denyduplicates = self.config.getDenyDuplicates(printer.Name) 
    241242            if not self.jobSizeBytes : 
    242243                # if no data to pass to real backend, probably a filter 
     
    245246                self.printMoreInfo(user, printer, _("Job contains no data. Printing is denied."), "warn") 
    246247                action = "DENY" 
    247             elif self.config.getDenyDuplicates(printer.Name) \ 
     248            elif denyduplicates \ 
    248249                 and printer.LastJob.Exists \ 
    249250                 and (printer.LastJob.UserName == user.Name) \ 
    250251                 and (printer.LastJob.JobMD5Sum == self.checksum) : 
    251                 self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 
    252                 action = "DENY"  
     252                if denyduplicates == 1 : 
     253                    self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 
     254                    action = "DENY" 
     255                else :     
     256                    self.logdebug("Launching subprocess [%s] to see if dupes should be allowed or not." % denyduplicates) 
     257                    fanswer = os.popen(denyduplicates, "r") 
     258                    action = fanswer.read().strip().upper() 
     259                    fanswer.close() 
     260                    if action == "DENY" :      
     261                        self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied by subprocess."), "warn") 
     262                    else :     
     263                        self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is allowed by subprocess."), "warn") 
     264                        action = "ALLOW" # just to be sure, in the case the external command returns something else... 
    253265            else :     
    254266                # checks the user's quota