Changeset 2759 for pykota/trunk/bin/cupspykota
- Timestamp:
- 02/27/06 19:00:44 (18 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2692 r2759 27 27 import sys 28 28 import os 29 import time 29 30 import errno 30 31 import tempfile … … 1018 1019 self.Action = "PROBLEM" 1019 1020 self.exportReason() 1020 if onbackenderror == "NOCHARGE":1021 if "NOCHARGE" in onbackenderror : 1021 1022 self.JobSize = 0 1022 1023 self.printInfo(_("Job size forced to 0 because the real CUPS backend failed. No accounting will be done."), "warn") … … 1033 1034 else : 1034 1035 self.UserPQuota.resetDenyBannerCounter() 1035 if (self.Action != "PROBLEM") or ( onbackenderror == "CHARGE") :1036 if (self.Action != "PROBLEM") or ("CHARGE" in onbackenderror) : 1036 1037 self.JobSize = self.accounter.getJobSize(self.Printer) 1037 1038 self.sanitizeJobSize() … … 1039 1040 self.printInfo(_("Job size : %i") % self.JobSize) 1040 1041 1041 if ((self.Action == "PROBLEM") and ( onbackenderror == "NOCHARGE")) or \1042 if ((self.Action == "PROBLEM") and ("NOCHARGE" in onbackenderror)) or \ 1042 1043 (self.Action in ("DENY", "CANCEL")) : 1043 1044 self.JobPrice = 0.0 … … 1061 1062 if hasattr(self, "BillingCode") and self.BillingCode and self.BillingCode.Exists : 1062 1063 if (self.Action in ("ALLOW", "WARN")) or \ 1063 ((self.Action == "PROBLEM") and ( onbackenderror == "CHARGE")) :1064 ((self.Action == "PROBLEM") and ("CHARGE" in onbackenderror)) : 1064 1065 self.BillingCode.consume(self.JobSize, self.JobPrice) 1065 1066 self.printInfo(_("Billing code %s was updated.") % self.BillingCode.BillingCode) … … 1087 1088 """Sends the job's datas to the real backend.""" 1088 1089 self.logdebug("Sending job's datas to real backend...") 1089 if self.InputFile is None : 1090 infile = open(self.DataFile, "rb") 1091 else : 1092 infile = None 1093 retcode = self.runOriginalBackend(infile) 1094 if self.InputFile is None : 1095 infile.close() 1090 1091 delay = 0 1092 number = 1 1093 for onb in self.config.getPrinterOnBackendError(self.PrinterName) : 1094 if onb.startswith("RETRY:") : 1095 try : 1096 (number, delay) = [int(p) for p in onb[6:].split(":", 2)] 1097 if (number < 0) or (delay < 0) : 1098 raise ValueError 1099 except ValueError : 1100 self.printInfo(_("Incorrect value for the 'onbackenderror' directive in section [%s]") % self.PrinterName, "error") 1101 delay = 0 1102 number = 1 1103 else : 1104 break 1105 loopcnt = 1 1106 while True : 1107 if self.InputFile is None : 1108 infile = open(self.DataFile, "rb") 1109 else : 1110 infile = None 1111 retcode = self.runOriginalBackend(infile) 1112 if self.InputFile is None : 1113 infile.close() 1114 if not retcode : 1115 break 1116 else : 1117 if (not number) or (loopcnt < number) : 1118 self.logdebug(_("The real backend produced an error, we will try again in %s seconds.") % delay) 1119 time.sleep(delay) 1120 loopcnt += 1 1121 else : 1122 break 1123 1096 1124 self.logdebug("Job's datas sent to real backend.") 1097 1125 return retcode