Changeset 1687 for pykota/trunk/pykota
- Timestamp:
- 09/01/04 01:29:53 (20 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounter.py
r1624 r1687 22 22 # 23 23 # $Log$ 24 # Revision 1.19 2004/08/31 23:29:53 jalet 25 # Introduction of the new 'onaccountererror' configuration directive. 26 # Small fix for software accounter's return code which can't be None anymore. 27 # Make software and hardware accounting code look similar : will be factorized 28 # later. 29 # 24 30 # Revision 1.18 2004/07/22 22:41:48 jalet 25 31 # Hardware accounting for LPRng should be OK now. UNTESTED. … … 97 103 self.filter = kotafilter 98 104 self.arguments = arguments 105 self.onerror = self.filter.config.getPrinterOnAccounterError(self.filter.printername) 99 106 self.isSoftware = 1 # by default software accounting 100 107 -
pykota/trunk/pykota/accounters/hardware.py
r1685 r1687 22 22 # 23 23 # $Log$ 24 # Revision 1.11 2004/08/31 23:29:53 jalet 25 # Introduction of the new 'onaccountererror' configuration directive. 26 # Small fix for software accounter's return code which can't be None anymore. 27 # Make software and hardware accounting code look similar : will be factorized 28 # later. 29 # 24 30 # Revision 1.10 2004/08/27 22:49:04 jalet 25 31 # No answer from subprocess now is really a fatal error. Waiting for some … … 154 160 except OSError, msg : 155 161 self.filter.logdebug("Error while waiting for hardware accounter pid %s : %s" % (child.pid, msg)) 156 if (pagecounter is not None) and os.WIFEXITED(status) and (not os.WEXITSTATUS(status)) :157 return pagecounter158 162 else : 159 raise PyKotaAccounterError, _("Unable to query printer %s via HARDWARE(%s)") % (printer, commandline) 163 if os.WIFEXITED(status) : 164 status = os.WEXITSTATUS(status) 165 self.filter.printInfo(_("Hardware accounter %s exit code is %s") % (self.arguments, str(status))) 160 166 167 if pagecounter is None : 168 message = _("Unable to query printer %s via HARDWARE(%s)") % (printer, commandline) 169 if self.onerror == "CONTINUE" : 170 self.filter.printInfo(message, "error") 171 else : 172 raise PyKotaAccounterError, message 173 return pagecounter -
pykota/trunk/pykota/accounters/software.py
r1680 r1687 22 22 # 23 23 # $Log$ 24 # Revision 1.10 2004/08/31 23:29:53 jalet 25 # Introduction of the new 'onaccountererror' configuration directive. 26 # Small fix for software accounter's return code which can't be None anymore. 27 # Make software and hardware accounting code look similar : will be factorized 28 # later. 29 # 24 30 # Revision 1.9 2004/08/25 22:34:39 jalet 25 31 # Now both software and hardware accounting raise an exception when no valid … … 99 105 100 106 try : 101 retcode= child.wait()107 status = child.wait() 102 108 except OSError, msg : 103 109 self.filter.printInfo(_("Problem while waiting for software accounter pid %s to exit : %s") % (child.pid, msg)) 104 110 else : 105 if os.WIFEXITED(retcode) : 106 status = os.WEXITSTATUS(retcode) 107 else : 108 status = retcode 111 if os.WIFEXITED(status) : 112 status = os.WEXITSTATUS(status) 109 113 self.filter.printInfo(_("Software accounter %s exit code is %s") % (self.arguments, str(status))) 110 114 111 115 if pagecounter is None : 112 raise PyKotaAccounterError, _("Unable to compute job size with accounter %s") % self.arguments 116 message = _("Unable to compute job size with accounter %s") % self.arguments 117 if self.onerror == "CONTINUE" : 118 self.filter.printInfo(message, "error") 119 else : 120 raise PyKotaAccounterError, message 113 121 114 self.filter.logdebug("Software accounter %s said job is %s pages long." % (self.arguments, pagecounter)) 115 return pagecounter 116 122 self.filter.logdebug("Software accounter %s said job is %s pages long." % (self.arguments, repr(pagecounter))) 123 return pagecounter or 0 -
pykota/trunk/pykota/config.py
r1646 r1687 22 22 # 23 23 # $Log$ 24 # Revision 1.51 2004/08/31 23:29:53 jalet 25 # Introduction of the new 'onaccountererror' configuration directive. 26 # Small fix for software accounter's return code which can't be None anymore. 27 # Make software and hardware accounting code look similar : will be factorized 28 # later. 29 # 24 30 # Revision 1.50 2004/07/27 07:07:27 jalet 25 31 # Typo : treshold ==> threshold … … 366 372 return enforcement 367 373 374 def getPrinterOnAccounterError(self, printername) : 375 """Returns what must be done whenever the accounter fails.""" 376 validactions = [ "CONTINUE", "STOP" ] 377 try : 378 action = self.getPrinterOption(printername, "onaccountererror") 379 except PyKotaConfigError : 380 return "STOP" 381 else : 382 action = action.upper() 383 if action not in validactions : 384 raise PyKotaConfigError, _("Option onaccountererror in section %s only supports values in %s") % (printername, str(validactions)) 385 return action 386 368 387 def getPrinterPolicy(self, printername) : 369 388 """Returns the default policy for the current printer.""" -
pykota/trunk/pykota/version.py
r1686 r1687 22 22 # 23 23 24 __version__ = "1.20alpha 4_unofficial"24 __version__ = "1.20alpha5_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""