Changeset 1433
- Timestamp:
- 04/10/04 00:24:47 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1411 r1433 24 24 # 25 25 # $Log$ 26 # Revision 1.38 2004/04/09 22:24:46 jalet 27 # Began work on correct handling of child processes when jobs are cancelled by 28 # the user. Especially important when an external requester is running for a 29 # long time. 30 # 26 31 # Revision 1.37 2004/03/18 19:11:25 jalet 27 32 # Fix for raw jobs in cupspykota … … 190 195 class PyKotaBackend(PyKotaFilterOrBackend) : 191 196 """A class for the pykota backend.""" 192 def __init__(self) :193 """Does normal initialization then installs signal handler."""194 # Normal init195 PyKotaFilterOrBackend.__init__(self)196 197 # then deal with signals198 # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM199 # Fortunately SIGPIPE is already ignored by Python200 # It's there just in case this changes in the future.201 # Here we have to handle SIGTERM correctly, and pass202 # it to the original backend if needed.203 self.gotSigTerm = 0204 signal.signal(signal.SIGPIPE, signal.SIG_IGN)205 signal.signal(signal.SIGTERM, self.sigterm_handler)206 207 def sigterm_handler(self, signum, frame) :208 """Sets a global variable whenever SIGTERM is received."""209 # SIGTERM will be ignore most of the time, but during210 # the call to the real backend, we have to pass it through.211 self.gotSigTerm = 1212 self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info")213 214 197 def acceptJob(self) : 215 198 """Returns the appropriate exit code to tell CUPS all is OK.""" -
pykota/trunk/pykota/accounters/querying.py
r1271 r1433 22 22 # 23 23 # $Log$ 24 # Revision 1.13 2004/04/09 22:24:47 jalet 25 # Began work on correct handling of child processes when jobs are cancelled by 26 # the user. Especially important when an external requester is running for a 27 # long time. 28 # 24 29 # Revision 1.12 2004/01/11 23:22:42 jalet 25 30 # Major code refactoring, it's way cleaner, and now allows automated addition … … 72 77 """Initializes querying accounter.""" 73 78 AccounterBase.__init__(self, kotabackend, arguments) 74 self.requester = openRequester(kotabackend .config, kotabackend.printername)79 self.requester = openRequester(kotabackend, kotabackend.printername) 75 80 self.isDelayed = 1 # With the pykota filter, accounting is delayed by one job 76 81 -
pykota/trunk/pykota/requester.py
r1257 r1433 22 22 # 23 23 # $Log$ 24 # Revision 1.13 2004/04/09 22:24:46 jalet 25 # Began work on correct handling of child processes when jobs are cancelled by 26 # the user. Especially important when an external requester is running for a 27 # long time. 28 # 24 29 # Revision 1.12 2004/01/08 14:10:32 jalet 25 30 # Copyright year changed. … … 73 78 __str__ = __repr__ 74 79 75 def openRequester( config, printername) :80 def openRequester(kotabackend, printername) : 76 81 """Returns a connection handle to the appropriate requester.""" 77 (backend, args) = config.getRequesterBackend(printername)82 (backend, args) = kotabackend.config.getRequesterBackend(printername) 78 83 try : 79 84 exec "from pykota.requesters import %s as requesterbackend" % backend.lower() … … 81 86 raise PyKotaRequesterError, _("Unsupported requester backend %s") % backend 82 87 else : 83 return requesterbackend.Requester( printername, args)88 return requesterbackend.Requester(kotabackend, printername, args) -
pykota/trunk/pykota/requesters/external.py
r1257 r1433 22 22 # 23 23 # $Log$ 24 # Revision 1.11 2004/04/09 22:24:47 jalet 25 # Began work on correct handling of child processes when jobs are cancelled by 26 # the user. Especially important when an external requester is running for a 27 # long time. 28 # 24 29 # Revision 1.10 2004/01/08 14:10:33 jalet 25 30 # Copyright year changed. … … 63 68 class Requester : 64 69 """A class to send queries to printers via external commands.""" 65 def __init__(self, printername, arguments) :70 def __init__(self, kotabackend, printername, arguments) : 66 71 """Sets instance vars depending on the current printer.""" 72 self.kotabackend = kotabackend 67 73 self.printername = printername 68 74 self.commandline = arguments.strip() -
pykota/trunk/pykota/requesters/snmp.py
r1257 r1433 22 22 # 23 23 # $Log$ 24 # Revision 1.14 2004/04/09 22:24:47 jalet 25 # Began work on correct handling of child processes when jobs are cancelled by 26 # the user. Especially important when an external requester is running for a 27 # long time. 28 # 24 29 # Revision 1.13 2004/01/08 14:10:33 jalet 25 30 # Copyright year changed. … … 76 81 class Requester : 77 82 """A class to send queries to printers via SNMP.""" 78 def __init__(self, printername, arguments) :83 def __init__(self, kotabackend, printername, arguments) : 79 84 """Sets instance vars depending on the current printer.""" 85 self.kotabackend = kotabackend 80 86 self.printername = printername 81 87 args = [x.strip() for x in arguments.split(',')] -
pykota/trunk/pykota/tool.py
r1426 r1433 22 22 # 23 23 # $Log$ 24 # Revision 1.81 2004/04/09 22:24:47 jalet 25 # Began work on correct handling of child processes when jobs are cancelled by 26 # the user. Especially important when an external requester is running for a 27 # long time. 28 # 24 29 # Revision 1.80 2004/04/06 12:00:21 jalet 25 30 # uninitialized values caused problems … … 741 746 self.exportJobInfo() 742 747 748 # then deal with signals 749 # CUPS backends ignore SIGPIPE and exit(1) on SIGTERM 750 # Fortunately SIGPIPE is already ignored by Python 751 # It's there just in case this changes in the future. 752 # Here we have to handle SIGTERM correctly, and pass 753 # it to any child if needed. 754 self.gotSigTerm = 0 755 signal.signal(signal.SIGPIPE, signal.SIG_IGN) 756 signal.signal(signal.SIGTERM, self.sigterm_handler) 757 758 def sigterm_handler(self, signum, frame) : 759 """Sets a global variable whenever SIGTERM is received.""" 760 # SIGTERM will be ignore most of the time, but during 761 # the call to the real backend, we have to pass it through. 762 self.gotSigTerm = 1 763 self.logger.log_message(_("SIGTERM received, job %s cancelled.") % self.jobid, "info") 764 743 765 def exportJobInfo(self) : 744 766 """Exports job information to the environment."""