Ticket #49: tea4cups-possible-patch.txt

File tea4cups-possible-patch.txt, 1.7 kB (added by bpkroth, 15 years ago)

A quick patch that may provide the functionality I described, implemented using another "special" return code.

Line 
1Index: tea4cups
2===================================================================
3--- tea4cups    (revision 3512)
4+++ tea4cups    (working copy)
5@@ -1293,7 +1293,9 @@
6         retcode = self.runCommands("prehook", branches, serialize)
7         for p in [ (k, v) for (k, v) in self.pipes.items() if k != 0 ] :
8             os.close(p[1][1])
9-        if not self.isCancelled :
10+        if self.isCancelled :
11+            retcode = 5 # Job cancelled, for CUPS.
12+        elif not retcode :
13             if self.RealBackend :
14                 retcode = self.launchOriginalBackend()
15                 if retcode :
16@@ -1307,8 +1309,6 @@
17             branches = self.enumBranches(self.PrinterName, "posthook")
18             if self.runCommands("posthook", branches, serialize) :
19                 self.logInfo("An error occured during the execution of posthooks.", "warn")
20-        else :
21-            retcode = 5 # Job cancelled, for CUPS.
22         for p in [ (k, v) for (k, v) in self.pipes.items() if k != 0 ] :
23             os.close(p[1][0])
24         if not retcode :
25@@ -1366,6 +1366,10 @@
26                     if (btype == "prehook") and (retcode == 255) : # -1
27                         self.logInfo("Job %s cancelled by prehook %s" % (self.JobId, branch))
28                         self.isCancelled = 1
29+                    elif (btype == "prehook") and (retcode == 254) : # -2
30+                        self.logInfo("Job %s hook processing stopped by prehook %s" % (self.JobId, branch))
31+                        exitcode = 1
32+                        break
33                     else :
34                         self.logInfo("%s %s on printer %s didn't exit successfully." % (btypetitle, branch, self.PrinterName), "error")
35                         exitcode = 1