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

Added the possibility for prehooks to cancel print jobs

Files:
1 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)