- Timestamp:
- 05/18/04 16:49:34 (21 years ago)
- Location:
- pykota/trunk
- Files:
-
- 2 removed
- 29 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r1478 r1483 24 24 # 25 25 # $Log$ 26 # Revision 1.44 2004/05/18 14:48:47 jalet 27 # Big code changes to completely remove the need for "requester" directives, 28 # jsut use "hardware(... your previous requester directive's content ...)" 29 # 26 30 # Revision 1.43 2004/05/17 11:46:05 jalet 27 31 # First try at cupspykota's main loop rewrite … … 186 190 from pykota.storage import PyKotaStorageError 187 191 from pykota.accounter import PyKotaAccounterError 188 from pykota.requester import PyKotaRequesterError189 192 190 193 class PyKotaPopen4(popen2.Popen4) : … … 508 511 kotabackend = PyKotaBackend() 509 512 retcode = kotabackend.mainWork() 510 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, PyKotaRequesterError,AttributeError, KeyError, IndexError, ValueError, TypeError, IOError), msg :513 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, AttributeError, KeyError, IndexError, ValueError, TypeError, IOError), msg : 511 514 import traceback 512 515 mm = [((f.endswith('\n') and f) or (f + '\n')) for f in traceback.format_exception(*sys.exc_info())] -
pykota/trunk/bin/pkhint
r1475 r1483 24 24 # 25 25 # $Log$ 26 # Revision 1.8 2004/05/18 14:48:47 jalet 27 # Big code changes to completely remove the need for "requester" directives, 28 # jsut use "hardware(... your previous requester directive's content ...)" 29 # 26 30 # Revision 1.7 2004/05/13 13:59:27 jalet 27 31 # Code simplifications … … 214 218 snmpcommand = self.accepts(SNMPTESTS, hostname) 215 219 if snmpcommand is not None : 216 accounter = "hardware" 217 requester = 'external(/usr/share/pykota/waitprinter.sh %(printer)s && ' + snmpcommand + ')' 218 configuration.append((printer, accounter, requester)) 220 accounter = 'hardware(/usr/share/pykota/waitprinter.sh %(printer)s && ' + snmpcommand + ')' 221 configuration.append((printer, accounter)) 219 222 else : 220 223 netpjlcommand = self.accepts(NETPJLTESTS, hostname, port) 221 224 if netpjlcommand is not None : 222 accounter = "hardware" 223 requester = 'external(' + netpjlcommand + ')' 224 configuration.append((printer, accounter, requester)) 225 accounter = 'hardware(' + netpjlcommand + ')' 226 configuration.append((printer, accounter)) 225 227 elif devicetype == "direct" : 226 228 sys.stderr.write("Can't currently handle device %s for printer %s\n" % (device, printer)) … … 234 236 else : 235 237 print "\nPut the following lines into your /etc/pykota/pykota.conf file :\n" 236 for (printer, accounter , requester) in configuration :238 for (printer, accounter) in configuration : 237 239 print "[%s]" % printer 238 240 print "accounter: %s" % accounter 239 if requester is not None :240 print "requester: %s" % requester241 241 print 242 242 -
pykota/trunk/bin/pykota
r1400 r1483 24 24 # 25 25 # $Log$ 26 # Revision 1.58 2004/05/18 14:48:47 jalet 27 # Big code changes to completely remove the need for "requester" directives, 28 # jsut use "hardware(... your previous requester directive's content ...)" 29 # 26 30 # Revision 1.57 2004/03/15 10:47:56 jalet 27 31 # This time the traceback formatting should be correct ! … … 233 237 from pykota.storage import PyKotaStorageError 234 238 from pykota.accounter import PyKotaAccounterError 235 from pykota.requester import PyKotaRequesterError236 239 237 240 class PyKotaFilter(PyKotaFilterOrBackend) : … … 359 362 kotafilter = PyKotaFilter() 360 363 retcode = kotafilter.mainWork() 361 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, PyKotaRequesterError,AttributeError, KeyError, IndexError, ValueError, TypeError, IOError), msg :364 except (PyKotaToolError, PyKotaConfigError, PyKotaStorageError, PyKotaAccounterError, AttributeError, KeyError, IndexError, ValueError, TypeError, IOError), msg : 362 365 import traceback 363 366 mm = [((f.endswith('\n') and f) or (f + '\n')) for f in traceback.format_exception(*sys.exc_info())] -
pykota/trunk/conf/pykota.conf.sample
r1475 r1483 187 187 # default in PyKota since its beginning. 188 188 # 189 # In the lines below "%(printer)s" is automatically replaced 190 # at run time with your printer's Fully Qualified Domain Name 191 # for network printers. 192 # e.g. myprinter.example.com 193 # 194 # Example : 195 # 196 # accounter: hardware(/usr/bin/snmpget -v1 -c public -Ov %(printer)s mib-2.43.10.2.1.4.1.1 | cut -f 2,2 -d " ") 197 # 198 # Another untested example, using npadmin : 199 # 200 # accounter: hardware(/usr/bin/npadmin --pagecount %(printer)s) 201 # 202 # Another example, for AppleTalk printers which works fine : 203 # (You may need the pap CUPS backend installed, and copy the 204 # pagecount.ps file from untested/netatalk into /etc or any 205 # appropriate location) 206 # 207 # accounter: hardware(/usr/share/pykota/papwaitprinter.sh "MyPrinter:LaserWriter@*" && /usr/bin/pap -p "MyPrinter:LaserWriter@*" /usr/share/pykota/pagecount.ps 2>/dev/null | /bin/grep -v status | /bin/grep -v Connect | /usr/bin/tail -1) 208 # 209 # An example for parallel printers like the HP Laserjet 5MP : 210 # 211 # accounter: hardware(/bin/cat /usr/share/pykota/pagecount.pjl >/dev/lp0 && /usr/bin/head -2 </dev/lp0 | /usr/bin/tail -1) 212 # 213 # This value can be set either globally or per printer or both. 214 # If both are defined, the printer option has priority. 215 # 216 # Some examples and comments provided by Bob Martel from csuohio.edu 217 # 218 # For several printers I could not get the page count using snmpget. I 219 # resorted to snmpwalk: 220 # 221 # accounter: hardware(/opt/local/net-snmp/bin/snmpwalk -v 1 -Cc -c public %(printer)s | grep mib-2.43.10.2.1.4.1.1 | cut -d " " -f4) 222 # 223 # The last example is still more ugly, some of the printers only provided 224 # their counters without names, but at least always on the same line: 225 # 226 # accounter: hardware(/opt/local/net-snmp/bin/snmpwalk -v 1 -Cc -c public -Ov %(printer)s | grep Counter32 | tail -2 | head -1 | cut -d " " -f2) 227 # 228 # An example using netcat and a preformatted PJL job which you can find 229 # in the untested/pjl directory, which is sent to a JetDirect print 230 # server on port 9100 : 231 # 232 # accounter: hardware(/bin/nc -w 2 %(printer)s 9100 </usr/share/pykota/pagecount.pjl | /usr/bin/tail -2) 233 # 234 # An example using the contributed pagecount.pl script which does 235 # the same as above, but should work on more printers : 236 # 237 # accounter: hardware(/usr/share/pykota/pagecount.pl %(printer)s 9100) 238 # 239 # WARNING : In any case, when using an hardware accounter, please test the command line outside 240 # of PyKota before. This will save you some headaches in case it doesn't work as expected. 241 # 242 # The waitprinter.sh is there to wait until the printer is idle again. 243 # This should prevent a job to be sent to the printer while another one is 244 # not yet finished (not all pages are printed, but the complete job is in 245 # the printer) 246 # 247 # YOU ABSOLUTELY HAVE TO BE SURE YOU HAVE A SCRIPT WHICH WAITS FOR THE 248 # PRINTER BEING READY BEFORE ASKING FOR ITS INTERNAL PAGE COUNTER. 249 # 250 # PYKOTA INCLUDES SUCH SCRIPTS FOR SNMP AND APPLETALK PRINTERS, MORE TO COME 251 # 252 # SOME OF THE ABOVE EXAMPLES DON'T USE SUCH A SCRIPT, YOU HAVE BEEN WARNED 253 # 254 # 189 255 # - software : delegates the job's size computation to any 190 256 # external command of your choice. … … 209 275 # This value can be set either globally or on a per printer basis 210 276 # If both are defined, the printer option has priority. 211 # if not set it defaults to 'hardware'. 212 # 213 # default value 214 accounter: hardware 277 # 278 # default value 279 accounter: hardware(/usr/share/pykota/waitprinter.sh %(printer)s && /usr/bin/snmpget -v1 -c public -Ov %(printer)s mib-2.43.10.2.1.4.1.1 | cut -f 2,2 -d " ") 215 280 # accounter: software(/usr/bin/pkpgcounter) 216 281 … … 317 382 [hpmarketing] 318 383 319 # How to query the hpmarketing printer for its page counter.320 # THIS IS ONLY USED IF YOU HAVE SET 'accounter' TO 'hardware'321 # JUST COMMENT IT OUT IF YOU USE ANY OTHER ACCOUNTING METHOD.322 # (it would be ignored anyway)323 #324 # In the lines below "%(printer)s" is automatically replaced325 # at run time with your printer's Fully Qualified Domain Name326 # for network printers.327 # e.g. myprinter.example.com328 #329 # Only value supported is : external(... your command here...)330 #331 # Example :332 #333 # requester: external(/usr/bin/snmpget -v1 -c public -Ov %(printer)s mib-2.43.10.2.1.4.1.1 | cut -f 2,2 -d " ")334 #335 # Another untested example, using npadmin :336 #337 # requester: external(/usr/bin/npadmin --pagecount %(printer)s)338 #339 # Another example, for AppleTalk printers which works fine :340 # (You may need the pap CUPS backend installed, and copy the341 # pagecount.ps file from untested/netatalk into /etc or any342 # appropriate location)343 #344 # requester: external(/usr/share/pykota/papwaitprinter.sh "MyPrinter:LaserWriter@*" && /usr/bin/pap -p "MyPrinter:LaserWriter@*" /usr/share/pykota/pagecount.ps 2>/dev/null | /bin/grep -v status | /bin/grep -v Connect | /usr/bin/tail -1)345 #346 # An example for parallel printers like the HP Laserjet 5MP :347 #348 # requester: external(/bin/cat /usr/share/pykota/pagecount.pjl >/dev/lp0 && /usr/bin/head -2 </dev/lp0 | /usr/bin/tail -1)349 #350 # This value can be set either globally or per printer or both.351 # If both are defined, the printer option has priority.352 #353 # Some examples and comments provided by Bob Martel from csuohio.edu354 #355 # For several printers I could not get the page count using snmpget. I356 # resorted to snmpwalk:357 #358 # requester: external(/opt/local/net-snmp/bin/snmpwalk -v 1 -Cc -c public %(printer)s | grep mib-2.43.10.2.1.4.1.1 | cut -d " " -f4)359 #360 # The last example is still more ugly, some of the printers only provided361 # their counters without names, but at least always on the same line:362 #363 # requester: external(/opt/local/net-snmp/bin/snmpwalk -v 1 -Cc -c public -Ov %(printer)s | grep Counter32 | tail -2 | head -1 | cut -d " " -f2)364 #365 # An example using netcat and a preformatted PJL job which you can find366 # in the untested/pjl directory, which is sent to a JetDirect print367 # server on port 9100 :368 #369 # requester: external(/bin/nc -w 2 %(printer)s 9100 </usr/share/pykota/pagecount.pjl | /usr/bin/tail -2)370 #371 # An example using the contributed pagecount.pl script which does372 # the same as above, but should work on more printers :373 #374 # requester: external(/usr/share/pykota/pagecount.pl %(printer)s 9100)375 #376 # WARNING : In any case, when using an external requester, please test the command line outside377 # of PyKota before. This will save you some headaches in case it doesn't work as expected.378 #379 # The waitprinter.sh is there to wait until the printer is idle again.380 # This should prevent a job to be sent to the printer while another one is381 # not yet finished (not all pages are printed, but the complete job is in382 # the printer)383 #384 # YOU ABSOLUTELY HAVE TO BE SURE YOU HAVE A SCRIPT WHICH WAITS FOR THE385 # PRINTER BEING READY BEFORE ASKING FOR ITS INTERNAL PAGE COUNTER.386 #387 # PYKOTA INCLUDES SUCH SCRIPTS FOR SNMP AND APPLETALK PRINTERS, MORE TO COME388 #389 # default value390 requester: external(/usr/share/pykota/waitprinter.sh %(printer)s && /usr/bin/snmpget -v1 -c public -Ov %(printer)s mib-2.43.10.2.1.4.1.1 | cut -f 2,2 -d " ")391 384 392 385 # Default policy for inexistant users (e.g. root) … … 395 388 # If both are defined, the printer option has priority. 396 389 # If the value is not set then the default policy DENY applies. 397 # ATTENTION :398 # Before 1.04 the default value was ALLOW, but unknown users399 # allowed to print causes accuracy problems : their jobs are400 # charged to the next person who prints on the same printer.401 390 # There's no policy wrt inexistant groups, they are ignored. 402 391 # … … 441 430 # List of available environment variables : 442 431 # NB : Most of these variables are also available during the execution 443 # of external commands defined in the accounter , requester ormailto432 # of external commands defined in the accounter and mailto 444 433 # directives. 445 434 # -
pykota/trunk/docs/scripts.sgml
r1406 r1483 21 21 22 22 <para> 23 When defining an external <literal>requester</literal> for a printer, it is important to wait for the printer being23 When defining an hardware <literal>accounter</literal> for a printer, it is important to wait for the printer being 24 24 <literal>idle</literal> before asking it for its internal page counter, otherwise results could 25 25 be inaccurate. If the printer is asked while the job is still being printed, then the page counter's … … 49 49 50 50 <para> 51 When defining an external <literal>requester</literal> for a printer, it is important to wait for the printer being51 When defining an hardware <literal>accounter</literal> for a printer, it is important to wait for the printer being 52 52 <literal>idle</literal> before asking it for its internal page counter, otherwise results could 53 53 be inaccurate. If the printer is asked while the job is still being printed, then the page counter's … … 92 92 <title>pagecount.pl</title> 93 93 <para> 94 This <application>Perl</application> script can be used in the <literal> requester</literal> directive of <filename>pykota.conf</filename>,94 This <application>Perl</application> script can be used in the <literal>accounter</literal> directive of <filename>pykota.conf</filename>, 95 95 to ask a printer for its internal page counter by sending a specially crafted <acronym>PJL</acronym> job 96 96 to it over the AppSocket protocol, usually on <acronym>TCP</acronym> port 9100. … … 103 103 to be in <literal>idle</literal> state, in something like : 104 104 <screen> 105 requester: external(somewaitscript.sh && pagecount.pl %(printer)s)105 accounter: hardware(somewaitscript.sh && pagecount.pl %(printer)s) 106 106 </screen> 107 107 </para> … … 119 119 120 120 $Log$ 121 Revision 1.2 2004/05/18 14:48:48 jalet 122 Big code changes to completely remove the need for "requester" directives, 123 jsut use "hardware(... your previous requester directive's content ...)" 124 121 125 Revision 1.1 2004/03/16 14:42:31 jalet 122 126 Improved documentation -
pykota/trunk/NEWS
r1482 r1483 22 22 PyKota NEWS : 23 23 24 - 1.19alpha10 : 25 26 - configuration simplifications : the "accounter" directive's 27 'hardware' arguments now accepts what was in the "requester" 28 directive as it's content. The "requester" directive is not 29 supported anymore. See sample configuration file for details. 30 24 31 - 1.19alpha9 : 25 32 -
pykota/trunk/po/br/pykota.po
r1470 r1483 172 172 173 173 #, python-format 174 msgid "Invalid externalaccounter %s for printer %s"175 msgstr "Contador de p�nas externo%s inv�do, para a impressora %s"174 msgid "Invalid accounter %s for printer %s" 175 msgstr "Contador de p�nas %s inv�do, para a impressora %s" 176 176 177 177 #, python-format 178 178 msgid "Option accounter in section %s only supports values in %s" 179 179 msgstr "A op� accounter na se� %s s�porta valores em %s" 180 181 #, python-format182 msgid "Option requester for printer %s was not set"183 msgstr "A op� requester para a impressora %s n�foi configurada "184 185 #, python-format186 msgid "Invalid requester %s for printer %s"187 msgstr "Requester inv�do %s para a impressora %s"188 189 #, python-format190 msgid "Option requester for printer %s only supports values in %s"191 msgstr "a op� requester para a impresora %s s�porta valores em %s"192 180 193 181 #, python-format … … 291 279 292 280 #, python-format 293 msgid "Unsupported requester backend %s"294 msgstr "Requester backend %s n�suportado"295 296 #, python-format297 281 msgid "Unsupported quota storage backend %s" 298 282 msgstr "o banco de dados: %s n�suportado" … … 438 422 439 423 #, python-format 440 msgid "Unable to compute job size with externalaccounter %s"441 msgstr "Impossivel calcular o tamanho do trabalho com o contador externo%s"424 msgid "Unable to compute job size with accounter %s" 425 msgstr "Impossivel calcular o tamanho do trabalho com o contador %s" 442 426 443 427 msgid "Using the 'stupid' accounting method is unreliable." … … 448 432 449 433 #, python-format 450 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"451 msgstr "Endere�invalido em EXTERNAL(%s) para a impressora %s"452 453 #, python-format 454 msgid "Unable to query printer %s via EXTERNAL(%s)"455 msgstr "Imposive consultar a impressora %s via EXTERNAL(%s)"434 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 435 msgstr "Endere�invalido em HARDWARE(%s) para a impressora %s" 436 437 #, python-format 438 msgid "Unable to query printer %s via HARDWARE(%s)" 439 msgstr "Imposive consultar a impressora %s via HARDWARE(%s)" 456 440 457 441 #, python-format … … 496 480 497 481 #, python-format 498 msgid "SIGTERM was sent to external requester %s (pid: %s)"499 msgstr ""500 501 #, python-format502 482 msgid "Impossible to connect to SMTP server : %s" 503 483 msgstr "" -
pykota/trunk/po/en/pykota.po
r1470 r1483 174 174 175 175 #, python-format 176 msgid "Invalid externalaccounter %s for printer %s"176 msgid "Invalid accounter %s for printer %s" 177 177 msgstr "" 178 178 179 179 #, python-format 180 180 msgid "Option accounter in section %s only supports values in %s" 181 msgstr ""182 183 #, python-format184 msgid "Option requester for printer %s was not set"185 msgstr ""186 187 #, python-format188 msgid "Invalid requester %s for printer %s"189 msgstr ""190 191 #, python-format192 msgid "Option requester for printer %s only supports values in %s"193 181 msgstr "" 194 182 … … 278 266 #, python-format 279 267 msgid "Unsupported reporter backend %s" 280 msgstr ""281 282 #, python-format283 msgid "Unsupported requester backend %s"284 268 msgstr "" 285 269 … … 402 386 403 387 #, python-format 404 msgid "Unable to compute job size with externalaccounter %s"388 msgid "Unable to compute job size with accounter %s" 405 389 msgstr "" 406 390 … … 412 396 413 397 #, python-format 414 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"415 msgstr "" 416 417 #, python-format 418 msgid "Unable to query printer %s via EXTERNAL(%s)"398 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 399 msgstr "" 400 401 #, python-format 402 msgid "Unable to query printer %s via HARDWARE(%s)" 419 403 msgstr "" 420 404 … … 460 444 461 445 #, python-format 462 msgid "SIGTERM was sent to external requester %s (pid: %s)"463 msgstr ""464 465 #, python-format466 446 msgid "Impossible to connect to SMTP server : %s" 467 447 msgstr "" -
pykota/trunk/po/es/pykota.po
r1470 r1483 176 176 177 177 #, python-format 178 msgid "Invalid externalaccounter %s for printer %s"179 msgstr "Contador de p�nas externo%s inv�do, para la impresora %s"178 msgid "Invalid accounter %s for printer %s" 179 msgstr "Contador de p�nas %s inv�do, para la impresora %s" 180 180 181 181 #, python-format 182 182 msgid "Option accounter in section %s only supports values in %s" 183 183 msgstr "La opci�ccounter en la secci�s solo soporta valores en %s" 184 185 #, python-format186 msgid "Option requester for printer %s was not set"187 msgstr "La opci�equester para la impresora %s no ha sido establecida "188 189 #, python-format190 msgid "Invalid requester %s for printer %s"191 msgstr "Requester inv�do %s para la impresora %s"192 193 #, python-format194 msgid "Option requester for printer %s only supports values in %s"195 msgstr "La opci�equester para la impresora %s solo soporta valores en %s"196 184 197 185 #, python-format … … 295 283 296 284 #, python-format 297 msgid "Unsupported requester backend %s"298 msgstr "Requester backend %s no soportado "299 300 #, python-format301 285 msgid "Unsupported quota storage backend %s" 302 286 msgstr "Backend de almacenamiento de cuota no soportada %s" … … 439 423 440 424 #, python-format 441 msgid "Unable to compute job size with externalaccounter %s"442 msgstr "Imposible calcular el tama�el trabajo con el contador externo%s"425 msgid "Unable to compute job size with accounter %s" 426 msgstr "Imposible calcular el tama�el trabajo con el contador %s" 443 427 444 428 msgid "Using the 'stupid' accounting method is unreliable." … … 451 435 452 436 #, python-format 453 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"454 msgstr "Direcci�esconocida en EXTERNAL(%s) para la impresora %s"455 456 #, python-format 457 msgid "Unable to query printer %s via EXTERNAL(%s)"458 msgstr "Imposible consultar la impresora %s v� EXTERNAL(%s)"437 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 438 msgstr "Direcci�esconocida en HARDWARE(%s) para la impresora %s" 439 440 #, python-format 441 msgid "Unable to query printer %s via HARDWARE(%s)" 442 msgstr "Imposible consultar la impresora %s v�HARDWARE(%s)" 459 443 460 444 #, python-format … … 500 484 501 485 #, python-format 502 msgid "SIGTERM was sent to external requester %s (pid: %s)"503 msgstr ""504 505 #, python-format506 486 msgid "Impossible to connect to SMTP server : %s" 507 487 msgstr "" -
pykota/trunk/po/fr/pykota.po
r1474 r1483 181 181 182 182 #, python-format 183 msgid "Invalid externalaccounter %s for printer %s"184 msgstr "Compteur de pages externe%s invalide pour l'imprimante %s"183 msgid "Invalid accounter %s for printer %s" 184 msgstr "Compteur de pages %s invalide pour l'imprimante %s" 185 185 186 186 #, python-format … … 188 188 msgstr "" 189 189 "L'option accounter pour l'imprimante %s supporte seulement les valeurs %s" 190 191 #, python-format192 msgid "Option requester for printer %s was not set"193 msgstr "L'option requester pour l'imprimante %s n'a pas � d�nie"194 195 #, python-format196 msgid "Invalid requester %s for printer %s"197 msgstr "Requester %s invalide pour l'imprimante %s"198 199 #, python-format200 msgid "Option requester for printer %s only supports values in %s"201 msgstr ""202 "L'option requester pour l'imprimante %s supporte seulement les valeurs %s"203 190 204 191 #, python-format … … 298 285 msgstr "backend reporter %s non support� 299 286 #, python-format 300 msgid "Unsupported requester backend %s"301 msgstr "Backend requester %s non support�302 #, python-format303 287 msgid "Unsupported quota storage backend %s" 304 288 msgstr "Backend de stockage de quota %s non support� … … 428 412 msgstr "L'utilisateur %s n'a toujours pas de quota sur l'imprimante %s dans le syst� PyKota, le travail d'impression sera rejet� 429 413 #, python-format 430 msgid "Unable to compute job size with externalaccounter %s"431 msgstr "Impossible de calculer la taille du job avec le compteur externe%s"414 msgid "Unable to compute job size with accounter %s" 415 msgstr "Impossible de calculer la taille du job avec le compteur %s" 432 416 433 417 msgid "Using the 'stupid' accounting method is unreliable." … … 439 423 440 424 #, python-format 441 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"442 msgstr "Adresse inconnue dans EXTERNAL(%s) pour l'imprimante %s"443 444 #, python-format 445 msgid "Unable to query printer %s via EXTERNAL(%s)"446 msgstr "Impossible d'interroger l'imprimante %s via EXTERNAL(%s)"425 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 426 msgstr "Adresse inconnue dans HARDWARE(%s) pour l'imprimante %s" 427 428 #, python-format 429 msgid "Unable to query printer %s via HARDWARE(%s)" 430 msgstr "Impossible d'interroger l'imprimante %s via HARDWARE(%s)" 447 431 448 432 #, python-format … … 487 471 488 472 #, python-format 489 msgid "SIGTERM was sent to external requester %s (pid: %s)"490 msgstr ""491 492 #, python-format493 473 msgid "Impossible to connect to SMTP server : %s" 494 474 msgstr "Impossible de se connecter au serveur SMTP : %s" -
pykota/trunk/po/it/pykota.po
r1470 r1483 174 174 175 175 #, python-format 176 msgid "Invalid externalaccounter %s for printer %s"177 msgstr "Accounter esternonon valido %s per la stampante %s"176 msgid "Invalid accounter %s for printer %s" 177 msgstr "Accounter non valido %s per la stampante %s" 178 178 179 179 #, python-format 180 180 msgid "Option accounter in section %s only supports values in %s" 181 181 msgstr "L'opzione accounter nella sezione %s supporta solamente i seguenti valori %s" 182 183 #, python-format184 msgid "Option requester for printer %s was not set"185 msgstr "Opzione richiedente per la stampante %s non impostata"186 187 #, python-format188 msgid "Invalid requester %s for printer %s"189 msgstr "Richiedente non valido %s per la stampante %s"190 191 #, python-format192 msgid "Option requester for printer %s only supports values in %s"193 msgstr "Opzione requester per la stampante %s supporta solamente i seguenti valori %s"194 182 195 183 #, python-format … … 293 281 294 282 #, python-format 295 msgid "Unsupported requester backend %s"296 msgstr "Requester backend non supportato %s"297 298 #, python-format299 283 msgid "Unsupported quota storage backend %s" 300 284 msgstr "Storage delle quote non supportato %s" … … 439 423 440 424 #, python-format 441 msgid "Unable to compute job size with externalaccounter %s"442 msgstr "Impossibile calcolare la dimensione della stampa con il metodo external%s"425 msgid "Unable to compute job size with accounter %s" 426 msgstr "Impossibile calcolare la dimensione della stampa con il metodo %s" 443 427 444 428 msgid "Using the 'stupid' accounting method is unreliable." … … 449 433 450 434 #, python-format 451 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"452 msgstr "Indirizzo stampante sconosciuto per EXTERNAL(%s) per la stampante %s"453 454 #, python-format 455 msgid "Unable to query printer %s via EXTERNAL(%s)"456 msgstr "Impossibile ottenere informazioni dalla stampante %s via EXTERNAL(%s)"435 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 436 msgstr "Indirizzo stampante sconosciuto per HARDWARE(%s) per la stampante %s" 437 438 #, python-format 439 msgid "Unable to query printer %s via HARDWARE(%s)" 440 msgstr "Impossibile ottenere informazioni dalla stampante %s via HARDWARE(%s)" 457 441 458 442 #, python-format … … 493 477 494 478 #, python-format 495 msgid "SIGTERM was sent to external requester %s (pid: %s)"496 msgstr ""497 498 #, python-format499 479 msgid "Impossible to connect to SMTP server : %s" 500 480 msgstr "" -
pykota/trunk/po/pt/pykota.po
r1470 r1483 171 171 172 172 #, python-format 173 msgid "Invalid externalaccounter %s for printer %s"174 msgstr "Contador externode p�nas %s inv�do, para a impressora %s"173 msgid "Invalid accounter %s for printer %s" 174 msgstr "Contador de p�nas %s inv�do, para a impressora %s" 175 175 176 176 #, python-format 177 177 msgid "Option accounter in section %s only supports values in %s" 178 178 msgstr "A op� accounter na sec� %s s�porta valores em %s" 179 180 #, python-format181 msgid "Option requester for printer %s was not set"182 msgstr "A op� requester para a impressora %s n�foi configurada"183 184 #, python-format185 msgid "Invalid requester %s for printer %s"186 msgstr "Requester %s inv�do para a impressora %s"187 188 #, python-format189 msgid "Option requester for printer %s only supports values in %s"190 msgstr "A op� requester para a impresora %s s�porta valores em %s"191 179 192 180 #, python-format … … 290 278 291 279 #, python-format 292 msgid "Unsupported requester backend %s"293 msgstr "Backend requester %s n�suportado"294 295 #, python-format296 280 msgid "Unsupported quota storage backend %s" 297 281 msgstr "Base de dados %s n�suportada" … … 437 421 438 422 #, python-format 439 msgid "Unable to compute job size with externalaccounter %s"440 msgstr "Foi imposs�l calcular o tamanho do trabalho com o contador externo%s"423 msgid "Unable to compute job size with accounter %s" 424 msgstr "Foi imposs�l calcular o tamanho do trabalho com o contador %s" 441 425 442 426 msgid "Using the 'stupid' accounting method is unreliable." … … 448 432 449 433 #, python-format 450 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"451 msgstr "Endere�inv�do em EXTERNAL(%s) para a impressora %s"452 453 #, python-format 454 msgid "Unable to query printer %s via EXTERNAL(%s)"455 msgstr "Foi imposs�l consultar a impressora %s via EXTERNAL(%s)"434 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 435 msgstr "Endere�inv�do em HARDWARE(%s) para a impressora %s" 436 437 #, python-format 438 msgid "Unable to query printer %s via HARDWARE(%s)" 439 msgstr "Foi imposs�l consultar a impressora %s via HARDWARE(%s)" 456 440 457 441 #, python-format … … 496 480 497 481 #, python-format 498 msgid "SIGTERM was sent to external requester %s (pid: %s)"499 msgstr ""500 501 #, python-format502 482 msgid "Impossible to connect to SMTP server : %s" 503 483 msgstr "" -
pykota/trunk/po/pykota.pot
r1470 r1483 174 174 175 175 #, python-format 176 msgid "Invalid externalaccounter %s for printer %s"176 msgid "Invalid accounter %s for printer %s" 177 177 msgstr "" 178 178 179 179 #, python-format 180 180 msgid "Option accounter in section %s only supports values in %s" 181 msgstr ""182 183 #, python-format184 msgid "Option requester for printer %s was not set"185 msgstr ""186 187 #, python-format188 msgid "Invalid requester %s for printer %s"189 msgstr ""190 191 #, python-format192 msgid "Option requester for printer %s only supports values in %s"193 181 msgstr "" 194 182 … … 278 266 #, python-format 279 267 msgid "Unsupported reporter backend %s" 280 msgstr ""281 282 #, python-format283 msgid "Unsupported requester backend %s"284 268 msgstr "" 285 269 … … 402 386 403 387 #, python-format 404 msgid "Unable to compute job size with externalaccounter %s"388 msgid "Unable to compute job size with accounter %s" 405 389 msgstr "" 406 390 … … 412 396 413 397 #, python-format 414 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"415 msgstr "" 416 417 #, python-format 418 msgid "Unable to query printer %s via EXTERNAL(%s)"398 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 399 msgstr "" 400 401 #, python-format 402 msgid "Unable to query printer %s via HARDWARE(%s)" 419 403 msgstr "" 420 404 … … 460 444 461 445 #, python-format 462 msgid "SIGTERM was sent to external requester %s (pid: %s)"463 msgstr ""464 465 #, python-format466 446 msgid "Impossible to connect to SMTP server : %s" 467 447 msgstr "" -
pykota/trunk/po/se/pykota.po
r1470 r1483 174 174 175 175 #, python-format 176 msgid "Invalid externalaccounter %s for printer %s"177 msgstr "Ogiltig externredovisningsmetod %s f�rintern %s"176 msgid "Invalid accounter %s for printer %s" 177 msgstr "Ogiltig redovisningsmetod %s f�rintern %s" 178 178 179 179 #, python-format 180 180 msgid "Option accounter in section %s only supports values in %s" 181 181 msgstr "Variabeln 'accounter' i sektion '%s' st�r bara v�en i %s" 182 183 #, python-format184 msgid "Option requester for printer %s was not set"185 msgstr "Variabeln 'requester' f�rinter %s var inte satt"186 187 #, python-format188 msgid "Invalid requester %s for printer %s"189 msgstr "Ogiltigt v�e %s p�ariabeln 'requester' f�krivare %s"190 191 #, python-format192 msgid "Option requester for printer %s only supports values in %s"193 msgstr "Variabeln 'requester' f�krivare %s st�r bara v�en i %s"194 182 195 183 #, python-format … … 292 280 293 281 #, python-format 294 msgid "Unsupported requester backend %s"295 msgstr "Ej underst�metod %s f�ariablen 'requester'"296 297 #, python-format298 282 msgid "Unsupported quota storage backend %s" 299 283 msgstr "Ej underst�metod %s f�tt lagra data" … … 438 422 439 423 #, python-format 440 msgid "Unable to compute job size with externalaccounter %s"441 msgstr "Kunde inte ber�a utskriftsstorlek med externmetod %s"424 msgid "Unable to compute job size with accounter %s" 425 msgstr "Kunde inte ber�a utskriftsstorlek med metod %s" 442 426 443 427 msgid "Using the 'stupid' accounting method is unreliable." … … 448 432 449 433 #, python-format 450 msgid "Unknown printer address in EXTERNAL(%s) for printer %s"451 msgstr "Ok� skrivaradress i EXTERNAL(%s) f�krivare %s"452 453 #, python-format 454 msgid "Unable to query printer %s via EXTERNAL(%s)"455 msgstr "Kunde inte h�a information fr�skrivare %s via EXTERNAL(%s)"434 msgid "Unknown printer address in HARDWARE(%s) for printer %s" 435 msgstr "Ok� skrivaradress i HARDWARE(%s) f�krivare %s" 436 437 #, python-format 438 msgid "Unable to query printer %s via HARDWARE(%s)" 439 msgstr "Kunde inte h�a information fr�skrivare %s via HARDWARE(%s)" 456 440 457 441 #, python-format … … 492 476 493 477 #, python-format 494 msgid "SIGTERM was sent to external requester %s (pid: %s)"495 msgstr ""496 497 #, python-format498 478 msgid "Impossible to connect to SMTP server : %s" 499 479 msgstr "" -
pykota/trunk/pykota/accounter.py
r1285 r1483 22 22 # 23 23 # $Log$ 24 # Revision 1.14 2004/05/18 14:49:19 jalet 25 # Big code changes to completely remove the need for "requester" directives, 26 # jsut use "hardware(... your previous requester directive's content ...)" 27 # 24 28 # Revision 1.13 2004/01/12 22:43:40 jalet 25 29 # New formula to compute a job's price … … 63 67 64 68 import sys 69 from pykota import pdlanalyzer 65 70 66 71 class PyKotaAccounterError(Exception): … … 80 85 self.arguments = arguments 81 86 self.isDelayed = 0 # Accounting is immediate by default 87 self.firstPassSize = None 88 89 def getSoftwareJobSize(self) : 90 """Pre-computes the job's size with a software method.""" 91 if self.filter.preserveinputfile is None : 92 raise PyKotaAccounterError, "Only supports raw jobs for now.""" 93 else : 94 fname = self.filter.preserveinputfile 95 parser = pdfanalyzer.PDLAnalyzer(fname) 96 try : 97 jobsize = parser.getJobSize() 98 except TypeError, msg : 99 raise PyKotaAccounterError, msg 100 else : 101 self.firstPassSize = jobsize 82 102 83 103 def getLastPageCounter(self) : 84 104 """Returns last internal page counter value (possibly faked).""" 85 105 try : 86 return self.LastPageCounter 106 return self.LastPageCounter or 0 87 107 except : 88 108 return 0 -
pykota/trunk/pykota/accounters/hardware.py
r1475 r1483 22 22 # 23 23 # $Log$ 24 # Revision 1.2 2004/05/18 14:49:22 jalet 25 # Big code changes to completely remove the need for "requester" directives, 26 # jsut use "hardware(... your previous requester directive's content ...)" 27 # 24 28 # Revision 1.1 2004/05/13 13:59:30 jalet 25 29 # Code simplifications … … 30 34 import sys 31 35 import os 36 import popen2 32 37 from pykota.accounter import AccounterBase, PyKotaAccounterError 33 from pykota.requester import openRequester, PyKotaRequesterError34 38 35 39 class Accounter(AccounterBase) : … … 37 41 """Initializes querying accounter.""" 38 42 AccounterBase.__init__(self, kotabackend, arguments) 39 self.requester = openRequester(kotabackend, kotabackend.printername)40 43 self.isDelayed = 1 # With the pykota filter, accounting is delayed by one job 41 44 … … 44 47 self.filter.logdebug("Reading printer's internal page counter...") 45 48 try : 46 counter = self. requester.getPrinterPageCounter(self.filter.printerhostname)47 except PyKota RequesterError, msg :49 counter = self.askPrinterPageCounter(self.filter.printerhostname) 50 except PyKotaAccounterError, msg : 48 51 # can't get actual page counter, assume printer is off or warming up 49 52 # log the message anyway. … … 97 100 userpquota.Printer.addJobToHistory(self.filter.jobid, userpquota.User, counterbeforejob, action, filename=self.filter.preserveinputfile, title=self.filter.title, copies=self.filter.copies, options=self.filter.options) 98 101 return action 102 103 def askPrinterPageCounter(self, printer) : 104 """Returns the page counter from the printer via an external command. 105 106 The external command must report the life time page number of the printer on stdout. 107 """ 108 commandline = self.arguments.strip() % locals() 109 if printer is None : 110 raise PyKotaAccounterError, _("Unknown printer address in HARDWARE(%s) for printer %s") % (commandline, self.filter.printername) 111 error = 1 112 pagecounter = None 113 child = popen2.Popen4(commandline) 114 try : 115 pagecounter = int(child.fromchild.readline().strip()) 116 except ValueError : 117 pass 118 except IOError : 119 # we were interrupted by a signal, certainely a SIGTERM 120 # caused by the user cancelling the current job 121 try : 122 os.kill(child.pid, signal.SIGTERM) 123 except : 124 pass # already killed ? 125 self.filter.logger.log_message(_("SIGTERM was sent to hardware accounter %s (pid: %s)") % (commandline, child.pid), "info") 126 else : 127 error = 0 128 child.fromchild.close() 129 child.tochild.close() 130 status = child.wait() 131 if (not error) and os.WIFEXITED(status) and (not os.WEXITSTATUS(status)) : 132 return pagecounter 133 else : 134 raise PyKotaAccounterError, _("Unable to query printer %s via HARDWARE(%s)") % (printer, commandline) 99 135 -
pykota/trunk/pykota/accounters/software.py
r1475 r1483 22 22 # 23 23 # $Log$ 24 # Revision 1.2 2004/05/18 14:49:23 jalet 25 # Big code changes to completely remove the need for "requester" directives, 26 # jsut use "hardware(... your previous requester directive's content ...)" 27 # 24 28 # Revision 1.1 2004/05/13 13:59:30 jalet 25 29 # Code simplifications … … 45 49 infile = open(self.filter.inputfile, "rb") 46 50 47 # launches externalaccounter51 # launches software accounter 48 52 # TODO : USE tempfile.mkstemp() instead ! Needs some work ! 49 53 infilename = tempfile.mktemp() … … 68 72 # check exit status 69 73 if (os.WIFEXITED(retcode) and not os.WEXITSTATUS(retcode)) or os.stat(errfilename) : 70 # tries to extract the job size from the externalaccounter's74 # tries to extract the job size from the software accounter's 71 75 # standard output 72 76 childoutput = open(outfilename, "r") … … 74 78 pagecount = int(childoutput.readline().strip()) 75 79 except (AttributeError, ValueError) : 76 self.filter.logger.log_message(_("Unable to compute job size with externalaccounter %s") % self.arguments)80 self.filter.logger.log_message(_("Unable to compute job size with accounter %s") % self.arguments) 77 81 pagecount = 0 78 82 childoutput.close() 79 83 else : 80 self.filter.logger.log_message(_("Unable to compute job size with externalaccounter %s") % self.arguments)84 self.filter.logger.log_message(_("Unable to compute job size with accounter %s") % self.arguments) 81 85 pagecount = 0 82 86 os.remove(infilename) … … 86 90 # TODO : temporary files may remain on the filesystem... 87 91 msg = "%s : %s" % (self.arguments, msg) 88 self.filter.logger.log_message(_("Unable to compute job size with externalaccounter %s") % msg)92 self.filter.logger.log_message(_("Unable to compute job size with accounter %s") % msg) 89 93 pagecount = 0 90 94 -
pykota/trunk/pykota/config.py
r1475 r1483 22 22 # 23 23 # $Log$ 24 # Revision 1.47 2004/05/18 14:49:20 jalet 25 # Big code changes to completely remove the need for "requester" directives, 26 # jsut use "hardware(... your previous requester directive's content ...)" 27 # 24 28 # Revision 1.46 2004/05/13 13:59:28 jalet 25 29 # Code simplifications … … 311 315 validaccounters = [ "hardware", "software" ] 312 316 fullaccounter = self.getPrinterOption(printername, "accounter").strip() 313 if fullaccounter.lower().startswith("software") : 317 flower = fullaccounter.lower() 318 if flower.startswith("software") or flower.startswith("hardware") : 314 319 try : 315 320 (accounter, args) = [x.strip() for x in fullaccounter.split('(', 1)] 316 321 except ValueError : 317 raise PyKotaConfigError, _("Invalid externalaccounter %s for printer %s") % (fullaccounter, printername)322 raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) 318 323 if args.endswith(')') : 319 324 args = args[:-1] 320 325 if not args : 321 raise PyKotaConfigError, _("Invalid externalaccounter %s for printer %s") % (fullaccounter, printername)326 raise PyKotaConfigError, _("Invalid accounter %s for printer %s") % (fullaccounter, printername) 322 327 return (accounter.lower(), args) 323 el if fullaccounter.lower() not in validaccounters:328 else : 324 329 raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printername, str(validaccounters)) 325 else :326 return (fullaccounter.lower(), None)327 330 328 331 def getPreHook(self, printername) : … … 340 343 return # No command to launch in the post-hook 341 344 342 def getRequesterBackend(self, printername) :343 """Returns the requester backend to use for a given printer, with its arguments."""344 try :345 fullrequester = self.getPrinterOption(printername, "requester")346 except PyKotaConfigError :347 # No requester defined, maybe it is not needed if accounting method348 # is not set to 'hardware', but if we are called, then the accounting349 # method really IS 'hardware', and so there's a big problem.350 raise PyKotaConfigError, _("Option requester for printer %s was not set") % printername351 else :352 try :353 (requester, args) = [x.strip() for x in fullrequester.split('(', 1)]354 except ValueError :355 raise PyKotaConfigError, _("Invalid requester %s for printer %s") % (fullrequester, printername)356 if args.endswith(')') :357 args = args[:-1]358 if not args :359 raise PyKotaConfigError, _("Invalid requester %s for printer %s") % (fullrequester, printername)360 validrequesters = [ "external" ]361 requester = requester.lower()362 if requester not in validrequesters :363 raise PyKotaConfigError, _("Option requester for printer %s only supports values in %s") % (printername, str(validrequesters))364 return (requester, args)365 366 345 def getPrinterPolicy(self, printername) : 367 346 """Returns the default policy for the current printer.""" -
pykota/trunk/pykota/Makefile.am
r1482 r1483 7 7 logger.py \ 8 8 reporter.py \ 9 requester.py \10 9 storage.py \ 11 10 tool.py \ … … 13 12 version.py 14 13 15 SUBDIRS = accounters loggers reporters requestersstorages14 SUBDIRS = accounters loggers reporters storages 16 15 -
pykota/trunk/pykota/tool.py
r1481 r1483 22 22 # 23 23 # $Log$ 24 # Revision 1.88 2004/05/18 14:49:20 jalet 25 # Big code changes to completely remove the need for "requester" directives, 26 # jsut use "hardware(... your previous requester directive's content ...)" 27 # 24 28 # Revision 1.87 2004/05/17 19:14:59 jalet 25 29 # Now catches SIGPIPE and SIGCHLD … … 764 768 self.options, \ 765 769 self.originalbackend) = self.extractInfoFromCupsOrLprng() 766 self.username = self.username or 'root' 770 self.username = self.username or 'root' # when printing test page from CUPS web interface, username is empty 767 771 if self.config.getUserNameToLower() : 768 772 self.username = self.username.lower() -
pykota/trunk/pykota/version.py
r1478 r1483 22 22 # 23 23 24 __version__ = "1.19alpha 9_unofficial"24 __version__ = "1.19alpha10_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/setup.py
r1476 r1483 24 24 # 25 25 # $Log$ 26 # Revision 1.42 2004/05/18 14:48:46 jalet 27 # Big code changes to completely remove the need for "requester" directives, 28 # jsut use "hardware(... your previous requester directive's content ...)" 29 # 26 30 # Revision 1.41 2004/05/13 14:17:32 jalet 27 31 # Warning about changed accounter and requester directives … … 301 305 302 306 # now checks if pre-1.19alpha8 code is still there 303 for module in ["accounters/querying", "accounters/external", "requesters/snmp" ] :307 for module in ["accounters/querying", "accounters/external", "requesters/snmp", "requesters/external"] : 304 308 checkOldModule(module) 305 309 … … 377 381 dummy = raw_input("Please press ENTER when you have read the message above. ") 378 382 379 sys.stdout.write("\n\nWARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha 8 TO 1.19alpha8OR ABOVE\n")383 sys.stdout.write("\n\nWARNING : IF YOU ARE UPGRADING FROM A PRE-1.19alpha10 TO 1.19alpha10 OR ABOVE\n") 380 384 sys.stdout.write("YOU **MUST** MODIFY YOUR /etc/pykota/pykota.conf FILE BECAUSE accounter\n") 381 385 sys.stdout.write("AND requester DIRECTIVES SUPPORTED VALUES HAVE CHANGED.\n\n") 382 386 sys.stdout.write("YOU CAN DO THAT AFTER THE INSTALLATION IS FINISHED, OR PRESS CTRL+C NOW.\n") 383 sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha 8OR ABOVE.\n\n")387 sys.stdout.write("\n\nYOU DON'T HAVE ANYTHING SPECIAL TO DO IF THIS IS YOUR FIRST INSTALLATION\nOR IF YOU ARE ALREADY RUNNING VERSION 1.19alpha10 OR ABOVE.\n\n") 384 388 dummy = raw_input("Please press ENTER when you have read the message above. ") 385 389 … … 442 446 author_email = "alet@librelogiciel.com", 443 447 url = "http://www.librelogiciel.com/software/", 444 packages = [ "pykota", "pykota.storages", "pykota. requesters", "pykota.loggers", "pykota.accounters", "pykota.reporters" ],448 packages = [ "pykota", "pykota.storages", "pykota.loggers", "pykota.accounters", "pykota.reporters" ], 445 449 scripts = [ "bin/pkpgcounter", "bin/snmpprinterstatus", "bin/edpykota", "bin/repykota", "bin/warnpykota", "bin/pykotme", "bin/pkprinters", "bin/pkhint" ], 446 450 data_files = data_files) -
pykota/trunk/untested/README
r1257 r1483 22 22 This directory contains scripts which may be used to query printers 23 23 for their life time page counter, so you could define them as 24 external requesters in PyKota configuration file.24 hardware accounters in PyKota configuration file. 25 25 26 26 They are completely untested, and you certainely have to edit them to