Changeset 1475 for pykota/trunk/pykota
- Timestamp:
- 05/13/04 15:59:30 (20 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 2 added
- 4 removed
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/accounters/Makefile.am
r1417 r1475 2 2 3 3 pykota_accounters_PYTHON = \ 4 external.py \4 software.py \ 5 5 __init__.py \ 6 querying.py \ 7 stupid.py 6 hardware.py 8 7 -
pykota/trunk/pykota/config.py
r1371 r1475 22 22 # 23 23 # $Log$ 24 # Revision 1.46 2004/05/13 13:59:28 jalet 25 # Code simplifications 26 # 24 27 # Revision 1.45 2004/03/01 10:22:30 jalet 25 28 # Can now extract per printer pre and post hooks from the configuration file … … 303 306 """Returns the accounter backend to use for a given printer. 304 307 305 if it is not set, it defaults to ' querying' which means ask printer308 if it is not set, it defaults to 'hardware' which means ask printer 306 309 for its internal lifetime page counter. 307 310 """ 308 validaccounters = [ " querying", "stupid", "external" ]311 validaccounters = [ "hardware", "software" ] 309 312 fullaccounter = self.getPrinterOption(printername, "accounter").strip() 310 if fullaccounter.lower().startswith(" external") :313 if fullaccounter.lower().startswith("software") : 311 314 try : 312 315 (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] … … 343 346 except PyKotaConfigError : 344 347 # No requester defined, maybe it is not needed if accounting method 345 # is not set to ' querying', but if we are called, then the accounting346 # method really IS ' querying', and so there's a big problem.348 # is not set to 'hardware', but if we are called, then the accounting 349 # method really IS 'hardware', and so there's a big problem. 347 350 raise PyKotaConfigError, _("Option requester for printer %s was not set") % printername 348 351 else : … … 355 358 if not args : 356 359 raise PyKotaConfigError, _("Invalid requester %s for printer %s") % (fullrequester, printername) 357 validrequesters = [ " snmp", "external" ] # TODO : add more requesters360 validrequesters = [ "external" ] 358 361 requester = requester.lower() 359 362 if requester not in validrequesters : -
pykota/trunk/pykota/requesters/external.py
r1433 r1475 22 22 # 23 23 # $Log$ 24 # Revision 1.12 2004/05/13 13:59:30 jalet 25 # Code simplifications 26 # 24 27 # Revision 1.11 2004/04/09 22:24:47 jalet 25 28 # Began work on correct handling of child processes when jobs are cancelled by … … 63 66 # 64 67 68 import sys 65 69 import os 70 import popen2 71 import signal 66 72 from pykota.requester import PyKotaRequesterError 67 73 … … 82 88 if printer is None : 83 89 raise PyKotaRequesterError, _("Unknown printer address in EXTERNAL(%s) for printer %s") % (commandline, self.printername) 84 answer = os.popen(commandline) 90 error = 1 91 pagecounter = None 92 child = popen2.Popen4(commandline) 85 93 try : 86 pagecounter = int( answer.readline().strip())94 pagecounter = int(child.fromchild.readline().strip()) 87 95 except ValueError : 96 pass 97 except IOError : 98 # we were interrupted by a signal, certainely a SIGTERM 99 # caused by the user cancelling the current job 100 try : 101 os.kill(child.pid, signal.SIGTERM) 102 except : 103 pass # already killed ? 104 self.kotabackend.logger.log_message(_("SIGTERM was sent to external requester %s (pid: %s)") % (commandline, child.pid), "info") 105 else : 106 error = 0 107 child.fromchild.close() 108 child.tochild.close() 109 status = child.wait() 110 if (not error) and os.WIFEXITED(status) and (not os.WEXITSTATUS(status)) : 111 return pagecounter 112 else : 88 113 raise PyKotaRequesterError, _("Unable to query printer %s via EXTERNAL(%s)") % (printer, commandline) 89 answer.close()90 return pagecounter91 114 -
pykota/trunk/pykota/requesters/Makefile.am
r1417 r1475 3 3 pykota_requesters_PYTHON = \ 4 4 external.py \ 5 __init__.py \ 6 snmp.py 5 __init__.py 7 6 -
pykota/trunk/pykota/tool.py
r1469 r1475 22 22 # 23 23 # $Log$ 24 # Revision 1.86 2004/05/13 13:59:28 jalet 25 # Code simplifications 26 # 24 27 # Revision 1.85 2004/05/11 08:26:27 jalet 25 28 # Now catches connection problems to SMTP server … … 809 812 810 813 def prehook(self, userpquota) : 811 """Allows plug ing of an external hook before the job gets printed."""814 """Allows plugging of an external hook before the job gets printed.""" 812 815 prehook = self.config.getPreHook(userpquota.Printer.Name) 813 816 if prehook : … … 816 819 817 820 def posthook(self, userpquota) : 818 """Allows plug ing of an external hook after the job gets printed and/or denied."""821 """Allows plugging of an external hook after the job gets printed and/or denied.""" 819 822 posthook = self.config.getPostHook(userpquota.Printer.Name) 820 823 if posthook : -
pykota/trunk/pykota/version.py
r1473 r1475 22 22 # 23 23 24 __version__ = "1.19alpha 7_unofficial"24 __version__ = "1.19alpha8_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""