Changeset 980

Show
Ignore:
Timestamp:
04/30/03 21:53:58 (21 years ago)
Author:
jalet
Message:

1.05

Location:
pykota/trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r976 r980  
    6262#                 default in PyKota since its beginning. 
    6363# 
     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#  
    6471#    - stupid : counts the occurences of the 'showpage' postscript 
    6572#               statement in the document to be printed, only at 
     
    6875#               an example on how to implement your own accounting 
    6976#               method. 
    70 # 
    71 #    - more to be added in the future 
    7277# 
    7378# This value can be set either globally or on a per printer basis 
     
    106111[lp] 
    107112 
    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. 
    109116# Only snmp(community, oid) and external(command) are supported 
    110117# 
  • pykota/trunk/NEWS

    r978 r980  
    2222PyKota NEWS : 
    2323 
     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         
    2440    - 1.05alpha3 : 
    2541     
  • pykota/trunk/po/en/pykota.po

    r976 r980  
    2121# 
    2222# $Log$ 
     23# Revision 1.24  2003/04/30 19:53:58  jalet 
     24# 1.05 
     25# 
    2326# Revision 1.23  2003/04/30 13:36:40  jalet 
    2427# Stupid accounting method was added. 
     
    343346msgid "Using the 'stupid' accounting method is unreliable." 
    344347msgstr "" 
     348 
     349msgid "Invalid external accounter %s for printer %s" 
     350msgstr "" 
     351 
     352msgid "Unable to compute job size with external accounter %s" 
     353msgstr "" 
  • pykota/trunk/po/fr/pykota.po

    r976 r980  
    2121# 
    2222# $Log$ 
     23# Revision 1.23  2003/04/30 19:53:58  jalet 
     24# 1.05 
     25# 
    2326# Revision 1.22  2003/04/30 13:36:40  jalet 
    2427# Stupid accounting method was added. 
     
    355358msgid "Using the 'stupid' accounting method is unreliable." 
    356359msgstr "Utiliser la m�ode 'stupid' n'est pas fiable." 
     360 
     361msgid "Invalid external accounter %s for printer %s" 
     362msgstr "Compteur de pages externe %s invalide pour l'imprimante %s" 
     363 
     364msgid "Unable to compute job size with external accounter %s" 
     365msgstr "Impossible de calculer la taille du job avec le compteur externe %s" 
  • pykota/trunk/po/pykota.pot

    r976 r980  
    2121# 
    2222# $Log$ 
     23# Revision 1.24  2003/04/30 19:53:58  jalet 
     24# 1.05 
     25# 
    2326# Revision 1.23  2003/04/30 13:36:40  jalet 
    2427# Stupid accounting method was added. 
     
    343346msgid "Using the 'stupid' accounting method is unreliable." 
    344347msgstr "" 
     348 
     349msgid "Invalid external accounter %s for printer %s" 
     350msgstr "" 
     351 
     352msgid "Unable to compute job size with external accounter %s" 
     353msgstr "" 
  • pykota/trunk/pykota/accounter.py

    r976 r980  
    2121# 
    2222# $Log$ 
     23# Revision 1.3  2003/04/30 19:53:58  jalet 
     24# 1.05 
     25# 
    2326# Revision 1.2  2003/04/30 13:36:40  jalet 
    2427# Stupid accounting method was added. 
     
    4346class AccounterBase :     
    4447    """A class to account print usage by querying printers.""" 
    45     def __init__(self, kotafilter) : 
     48    def __init__(self, kotafilter, arguments) : 
    4649        """Sets instance vars depending on the current printer.""" 
    4750        self.filter = kotafilter 
     51        self.arguments = arguments 
    4852         
    4953    def filterInput(self, inputfile) : 
     
    7175def openAccounter(kotafilter) : 
    7276    """Returns a connection handle to the appropriate accounter.""" 
    73     backend = kotafilter.config.getAccounterBackend(kotafilter.printername) 
     77    (backend, args) = kotafilter.config.getAccounterBackend(kotafilter.printername) 
    7478    try : 
    7579        if not backend.isalpha() : 
     
    8084        raise PyKotaAccounterError, _("Unsupported accounter backend %s") % backend 
    8185    else :     
    82         return getattr(accounterbackend, "Accounter")(kotafilter) 
     86        return getattr(accounterbackend, "Accounter")(kotafilter, args) 
  • pykota/trunk/pykota/config.py

    r976 r980  
    2121# 
    2222# $Log$ 
     23# Revision 1.26  2003/04/30 19:53:58  jalet 
     24# 1.05 
     25# 
    2326# Revision 1.25  2003/04/30 13:36:40  jalet 
    2427# Stupid accounting method was added. 
     
    200203           for its internal lifetime page counter. 
    201204        """    
    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 : 
    208221            raise PyKotaConfigError, _("Option accounter in section %s only supports values in %s") % (printer, str(validaccounters)) 
    209         return accounter 
     222        else :     
     223            return (fullaccounter, None) 
    210224         
    211225    def getRequesterBackend(self, printer) :     
  • pykota/trunk/pykota/version.py

    r976 r980  
    2121# 
    2222 
    23 __version__ = "1.05alpha3-unofficial" 
     23__version__ = "1.05-unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" 
  • pykota/trunk/README

    r958 r980  
    6262          "untested" directory and try to adapt them to your 
    6363          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 ! 
    6469         
    6570        - Special scripts included for a seamless integration of 
     
    8792Planned features are described in the TODO file. 
    8893 
    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.  
     94Actually three (or an infinity of) page accounting methods are 
     95implemented : 
     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. 
    113114   
    114115PyKota 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. 
     116Apple LaserWriter 16/600 PS, both with CUPS and LPRng, under  
     117Debian GNU/Linux (Sarge and Sid) operating systems. 
     118 
     119I'm interested in receiving success or failure reports with other 
     120brands or models of printers, as well as with other operating  
     121systems. 
    126122 
    127123============================================================ 
     
    261257    along with totals. 
    262258     
    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. 
     259For different security concerns, please give a look at the SECURITY 
     260file which is part of this software. 
    279261            
    280262============================================================