Changeset 980
- Timestamp:
- 04/30/03 21:53:58 (22 years ago)
- Location:
- pykota/trunk
- Files:
-
- 10 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/conf/pykota.conf.sample
r976 r980 62 62 # default in PyKota since its beginning. 63 63 # 64 # - external : delegates the job's size computation to any 65 # external command of your choice. A stupid and 66 # completely unreliable example, but which 67 # shows what this command may be is : 68 # 69 # accounter: external(/bin/grep -c showpage) 70 # 64 71 # - stupid : counts the occurences of the 'showpage' postscript 65 72 # statement in the document to be printed, only at … … 68 75 # an example on how to implement your own accounting 69 76 # method. 70 #71 # - more to be added in the future72 77 # 73 78 # This value can be set either globally or on a per printer basis … … 106 111 [lp] 107 112 108 # How to query the lp printer for its page counter, if needed 113 # How to query the lp printer for its page counter. 114 # THIS IS ONLY USED IF YOU HAVE SET 'accounter' TO 'querying' 115 # JUST COMMENT IT OUT IF YOU USE ANY OTHER ACCOUNTING METHOD. 109 116 # Only snmp(community, oid) and external(command) are supported 110 117 # -
pykota/trunk/NEWS
r978 r980 22 22 PyKota NEWS : 23 23 24 - 1.05 : 25 26 - External accounters are finally available ! 27 This means that you can plug any page accounting 28 method you like by setting the appropriate 29 'accounter' field in /etc/pykota.conf 30 See the sample conf/pykota.conf.sample to 31 learn how to do. 32 33 NB : Both 'external' and 'stupid' accounting methods 34 account a job size just before *this* job is 35 sent to the printer. 36 The original 'querying' method accounts a job 37 size just before *the next* job is sent to 38 the printer. 39 24 40 - 1.05alpha3 : 25 41 -
pykota/trunk/po/en/pykota.po
r976 r980 21 21 # 22 22 # $Log$ 23 # Revision 1.24 2003/04/30 19:53:58 jalet 24 # 1.05 25 # 23 26 # Revision 1.23 2003/04/30 13:36:40 jalet 24 27 # Stupid accounting method was added. … … 343 346 msgid "Using the 'stupid' accounting method is unreliable." 344 347 msgstr "" 348 349 msgid "Invalid external accounter %s for printer %s" 350 msgstr "" 351 352 msgid "Unable to compute job size with external accounter %s" 353 msgstr "" -
pykota/trunk/po/fr/pykota.po
r976 r980 21 21 # 22 22 # $Log$ 23 # Revision 1.23 2003/04/30 19:53:58 jalet 24 # 1.05 25 # 23 26 # Revision 1.22 2003/04/30 13:36:40 jalet 24 27 # Stupid accounting method was added. … … 355 358 msgid "Using the 'stupid' accounting method is unreliable." 356 359 msgstr "Utiliser la m�ode 'stupid' n'est pas fiable." 360 361 msgid "Invalid external accounter %s for printer %s" 362 msgstr "Compteur de pages externe %s invalide pour l'imprimante %s" 363 364 msgid "Unable to compute job size with external accounter %s" 365 msgstr "Impossible de calculer la taille du job avec le compteur externe %s" -
pykota/trunk/po/pykota.pot
r976 r980 21 21 # 22 22 # $Log$ 23 # Revision 1.24 2003/04/30 19:53:58 jalet 24 # 1.05 25 # 23 26 # Revision 1.23 2003/04/30 13:36:40 jalet 24 27 # Stupid accounting method was added. … … 343 346 msgid "Using the 'stupid' accounting method is unreliable." 344 347 msgstr "" 348 349 msgid "Invalid external accounter %s for printer %s" 350 msgstr "" 351 352 msgid "Unable to compute job size with external accounter %s" 353 msgstr "" -
pykota/trunk/pykota/accounter.py
r976 r980 21 21 # 22 22 # $Log$ 23 # Revision 1.3 2003/04/30 19:53:58 jalet 24 # 1.05 25 # 23 26 # Revision 1.2 2003/04/30 13:36:40 jalet 24 27 # Stupid accounting method was added. … … 43 46 class AccounterBase : 44 47 """A class to account print usage by querying printers.""" 45 def __init__(self, kotafilter ) :48 def __init__(self, kotafilter, arguments) : 46 49 """Sets instance vars depending on the current printer.""" 47 50 self.filter = kotafilter 51 self.arguments = arguments 48 52 49 53 def filterInput(self, inputfile) : … … 71 75 def openAccounter(kotafilter) : 72 76 """Returns a connection handle to the appropriate accounter.""" 73 backend= kotafilter.config.getAccounterBackend(kotafilter.printername)77 (backend, args) = kotafilter.config.getAccounterBackend(kotafilter.printername) 74 78 try : 75 79 if not backend.isalpha() : … … 80 84 raise PyKotaAccounterError, _("Unsupported accounter backend %s") % backend 81 85 else : 82 return getattr(accounterbackend, "Accounter")(kotafilter )86 return getattr(accounterbackend, "Accounter")(kotafilter, args) -
pykota/trunk/pykota/config.py
r976 r980 21 21 # 22 22 # $Log$ 23 # Revision 1.26 2003/04/30 19:53:58 jalet 24 # 1.05 25 # 23 26 # Revision 1.25 2003/04/30 13:36:40 jalet 24 27 # Stupid accounting method was added. … … 200 203 for its internal lifetime page counter. 201 204 """ 202 validaccounters = [ "querying", "stupid" ] 203 try : 204 accounter = self.getPrinterOption(printer, "accounter").lower() 205 except PyKotaConfigError : 206 accounter = "querying" 207 if accounter not in validaccounters : 205 validaccounters = [ "querying", "stupid", "external" ] 206 try : 207 fullaccounter = self.getPrinterOption(printer, "accounter").strip().lower() 208 except PyKotaConfigError : 209 fullaccounter = "querying" 210 if fullaccounter.startswith("external") : 211 try : 212 (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] 213 except ValueError : 214 raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printer) 215 if args.endswith(')') : 216 args = args[:-1] 217 if not args : 218 raise PyKotaConfigError, _("Invalid external accounter %s for printer %s") % (fullaccounter, printer) 219 return (accounter, args) 220 elif fullaccounter not in validaccounters : 208 221 raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printer, str(validaccounters)) 209 return accounter 222 else : 223 return (fullaccounter, None) 210 224 211 225 def getRequesterBackend(self, printer) : -
pykota/trunk/pykota/version.py
r976 r980 21 21 # 22 22 23 __version__ = "1.05 alpha3-unofficial"23 __version__ = "1.05-unofficial" 24 24 25 25 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/README
r958 r980 62 62 "untested" directory and try to adapt them to your 63 63 configuration. 64 65 - External accounting methods : you can use your own accounting 66 method to compute each job's size. Just create a shell script 67 which prints the job's (read from its standard input) size on 68 its standard output, and you're done ! 64 69 65 70 - Special scripts included for a seamless integration of … … 87 92 Planned features are described in the TODO file. 88 93 89 Actually only the lazy quota method is implemented. What do I call 90 lazy method ? 91 92 The lazy method consists in querying the printer (actually via SNMP 93 or Netatalk) for its total pages counter, just before the beginning 94 of a job, and use this to modify the *preceding* user's quota. So 95 you're always late of one print job, but this is generally ok, 96 especially because a check is also done to see if the current user 97 is allowed or not to print. 98 99 Problem may theorically arise in batches of successive print jobs by 100 different users when there's no sleep time between two jobs : the 101 used pages may theorically be attributed to an incorrect user in the 102 case that the printer is asked for its page counter at the beginning 103 of a new job and before the end of the previous job. This depends on 104 the printer speed and time between jobs, but so far I've not seen 105 any problem with moderately used printers. This also depends on the 106 printing system's internal behavior : if it doesn't begin to send a 107 job to a printer before the previous one is completely printed, then 108 there's no problem. 109 110 Other querying methods which won't suffer from this possible 111 problem, but probably from other ones ;-) will be implemented in the 112 future. 94 Actually three (or an infinity of) page accounting methods are 95 implemented : 96 97 - The 'querying' method consists in querying the printer (via SNMP 98 or Netatalk) for its total pages counter, just before the beginning 99 of a job, and use this to modify the *preceding* user's quota. So 100 you're always late of one print job, but this is generally ok, 101 especially because a check is also done to see if the current user 102 is allowed or not to print. You're not limited to SNMP or Netatalk, 103 because you can also use any external command instead if you want. 104 105 - The 'external' method consists in delegating the computation of the 106 job's size in number of pages to any external command of your choice. 107 The command can read the job's data from its standard input and MUST 108 output the job's size on its standard output. 109 110 - The 'stupid' method consists in counting the 'showpage' PostSript 111 statements in the job. THIS IS UNRELIABLE, but can serve as an 112 example if you plan to write your own accounting method for 113 integration into PyKota. 113 114 114 115 PyKota is known to work fine with HP Laserjet 2100 and 2200, and 115 Apple LaserWriter 16/600 PS. 116 117 It should also work fine with any printer capable of outputing 118 its lifetime printed pages counter via either SNMP or AppleTalk. 119 120 If your printers don't support SNMP or AppleTalk, then making them 121 work with PyKota is up to you. Some sample scripts which can query 122 non-SNMP printers for their lifetime page counter are included in 123 the ./untested directory. You'll have to test and adapt them though, 124 and define them as external requesters in the PyKota configuration 125 file. See the sample configuration file to learn how to do that. 116 Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under 117 Debian GNU/Linux (Sarge and Sid) operating systems. 118 119 I'm interested in receiving success or failure reports with other 120 brands or models of printers, as well as with other operating 121 systems. 126 122 127 123 ============================================================ … … 261 257 along with totals. 262 258 263 SECURITY : You should ensure that only the print quota administrator 264 can run the warnpykota command, but this is actually not 265 enforced in the program. Any user able to launch warnpykota 266 could flood over-quota users' email boxes. 267 268 You should ensure that only the print quota administrator 269 can run the edpykota command, but this is actually not 270 enforced in the program. Otherwise, any user could modify 271 his/her or other people's print quota. 272 273 launching : chmod 750 /usr/bin/warnpykota /usr/bin/edpykota 274 should make you reasonably safe. 275 276 also please ensure that only the printing daemon user 277 can launch the pykota command. Again this is not enforced 278 in the program. 259 For different security concerns, please give a look at the SECURITY 260 file which is part of this software. 279 261 280 262 ============================================================