Changeset 601

Show
Ignore:
Timestamp:
03/21/05 14:20:51 (18 years ago)
Author:
jerome
Message:

Added the possibility for prehooks to cancel print jobs

Location:
tea4cups/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • tea4cups/trunk/tea4cups

    r600 r601  
    3737from struct import unpack 
    3838 
    39 version = "1.5alpha" 
     39version = "2.00" 
    4040 
    4141class TeeError(Exception): 
     
    538538            if status : 
    539539                exitcode = status 
     540            if (branchtype == "prehook") and (os.environ.get("TEASTATUS", "") == "CANCELLED") : 
     541                break # We don't want to execute tees or posthooks in this case 
    540542        signal.signal(signal.SIGTERM, signal.SIG_IGN) 
    541543        if not exitcode : 
     
    567569                    retcode = os.WEXITSTATUS(retcode) 
    568570                if retcode :     
    569                     self.logInfo("%s %s on printer %s didn't exit successfully." % (btypetitle, branch, self.PrinterName), "error") 
    570                     exitcode = 1 
     571                    if (btype == "prehook") and (retcode == 255) : # -1 
     572                        self.logInfo("Job %s cancelled by prehook %s" % (self.JobId, branch)) 
     573                        os.environ["TEASTATUS"] = "CANCELLED" # and don't touch exitcode 
     574                    else :     
     575                        self.logInfo("%s %s on printer %s didn't exit successfully." % (btypetitle, branch, self.PrinterName), "error") 
     576                        exitcode = 1 
    571577            self.logDebug("End serialized %ss" % btypetitle) 
    572578        else :         
     
    601607                    retcode = os.WEXITSTATUS(retcode) 
    602608                if retcode :     
    603                     self.logInfo("%s %s (PID %s) on printer %s didn't exit successfully." % (btypetitle, branch, childpid, self.PrinterName), "error") 
    604                     exitcode = 1 
     609                    if (btype == "prehook") and (retcode == 255) : # -1 
     610                        self.logInfo("Job %s cancelled by prehook %s" % (self.JobId, branch)) 
     611                        os.environ["TEASTATUS"] = "CANCELLED" # and don't touch exitcode 
     612                    else :     
     613                        self.logInfo("%s %s (PID %s) on printer %s didn't exit successfully." % (btypetitle, branch, childpid, self.PrinterName), "error") 
     614                        exitcode = 1 
    605615                if branch == "Original backend" :     
    606616                    os.environ["TEASTATUS"] = str(retcode) 
  • tea4cups/trunk/tea4cups.conf

    r598 r601  
    107107# prehook_0 : echo "Your print job has been accepted" | smbclient -M $TEAUSERNAME 
    108108# posthook_0 : echo "Your print job has been printed with status $TEASTATUS" | smbclient -M $TEAUSERNAME 
     109# 
     110# NB : as a special feature, any prehook which exits with a -1 status (255)  
     111# causes the job to NOT be sent to the real backend, in which case TEASTATUS  
     112# value is the string CANCELLED. None of the tees and posthooks gets executed 
     113# in this case, but all remaining prehooks are still executed. 
     114#  
    109115 
    110116