[753] | 1 | <!-- $Id$ --> |
---|
| 2 | |
---|
| 3 | <chapter> |
---|
[865] | 4 | <title id="filter">The pykota filter</title> |
---|
| 5 | |
---|
| 6 | <para>Last modified on $Date$</para> |
---|
| 7 | |
---|
[753] | 8 | <para> |
---|
[1101] | 9 | To account for pages or eventually ink usage |
---|
| 10 | <footnote> |
---|
| 11 | <para> |
---|
| 12 | PyKota doesn't currently account for ink usage, it only accounts |
---|
| 13 | pages. To account for ink usage, you should use PrintBill instead. |
---|
| 14 | </para> |
---|
| 15 | </footnote> |
---|
| 16 | , you must plug your accounting |
---|
[959] | 17 | system somewhere into the printing system you use, be it either <application>CUPS</application> |
---|
| 18 | or <application>LPRng</application>. One way to do this without having |
---|
| 19 | to modify the printing system itself, is by using a <firstterm>filter</firstterm>. |
---|
[753] | 20 | </para> |
---|
[865] | 21 | |
---|
| 22 | <para> |
---|
| 23 | A filter is a computer program which takes data in one format as its input, and outputs the |
---|
| 24 | same data but transformed into another format. <application>CUPS</application> already |
---|
| 25 | contains many filters. For example there's one filter named <application>pstops</application> which accepts |
---|
| 26 | PostScript data as its input, and, as its name implies, outputs PostScript data too, but after having |
---|
| 27 | eventually rearranged the pages to fit several pages on a single sheet of paper, or other manipulations |
---|
[959] | 28 | like that. |
---|
[865] | 29 | </para> |
---|
| 30 | |
---|
| 31 | <para> |
---|
| 32 | The <application>pstops</application> filter described above is also in charge of doing basic page |
---|
| 33 | accounting, but <application>PyKota</application> currently doesn't use this facility since it may |
---|
| 34 | prove to be unreliable depending on the drivers used or if a paper jam occur for example. |
---|
| 35 | </para> |
---|
| 36 | |
---|
| 37 | <para> |
---|
[959] | 38 | <application>LPRng</application> can also use filters, one often used in combination with |
---|
| 39 | <application>LPRng</application> is <application>magicfilter</application> which can convert |
---|
| 40 | different input formats to native printers languages like PostScript or ESC/P2. |
---|
| 41 | </para> |
---|
| 42 | |
---|
| 43 | <para> |
---|
[865] | 44 | So to do its own accounting, <application>PyKota</application> has its own filter, named <application>pykota</application>, |
---|
[959] | 45 | which you have to plug into the different set of filters used by your printing system of choice. The procedure to |
---|
[865] | 46 | install the <application>pykota</application> filter is described in the |
---|
| 47 | <xref linkend="installation" endterm="installation"> chapter. |
---|
| 48 | </para> |
---|
| 49 | |
---|
| 50 | <para> |
---|
[959] | 51 | Currently with a <application>CUPS</application> backend, the <application>pykota</application> filter is used at the very last stage of the print mechanism, |
---|
[865] | 52 | just before the final data is sent to the printer, but it may eventually be used earlier with some |
---|
[1099] | 53 | modifications to <application>CUPS</application>'s filtering configuration. |
---|
| 54 | You can find in the mailing list archives of July 2003 an explanation on how to do this. |
---|
| 55 | This may allow you to use PyKota with a not-PostScript printer or with a PostScript printer |
---|
| 56 | which really needs to have |
---|
| 57 | a specific filter like <application>magicfilter</application> or <application>cupsomatic</application>. |
---|
[865] | 58 | </para> |
---|
| 59 | |
---|
| 60 | <para> |
---|
[959] | 61 | When used with an <application>LPRng</application> backend, the accounting filter is not defined the same way |
---|
| 62 | input filters are, so the problem described above doesn't exist, and <application>PyKota</application> |
---|
[1101] | 63 | may work with non-postscript printers, provided they can report their page counter and you know how to retrieve |
---|
| 64 | it. |
---|
[865] | 65 | </para> |
---|
| 66 | |
---|
[959] | 67 | <para> |
---|
| 68 | When you submit a print job, <application>pykota</application> is automatically launched by your printing system, |
---|
| 69 | so it has to detect which system you are using (<application>CUPS</application> or <application>LPRng</application>) |
---|
| 70 | and behave like if it was specifically designed for your printing system. Fortunately there's not a lot |
---|
| 71 | of differences, the more important one is the exit codes used to tell the printing environment if a job |
---|
| 72 | has to be accepted or rejected. |
---|
| 73 | </para> |
---|
| 74 | |
---|
| 75 | <para> |
---|
[1099] | 76 | When using the <literal>querying</literal> accounting method, |
---|
[959] | 77 | <application>pykota</application> then asks the printer for its internal page counter, read from the Quota DataBase the internal |
---|
| 78 | page counter for this printer when the previous job was launched, computes the difference, and report it as the |
---|
| 79 | previous job's size in the Quota DataBase. It then updates the last user's print quota and account balance, and |
---|
[1101] | 80 | warn him if he is over quota or if his account balance is below 0. Finally it checks if the user who launched the |
---|
[959] | 81 | current job is below or above his print quota, and either allow or deny the job's datas to pass to the underlying |
---|
| 82 | layer (the printer itself). |
---|
| 83 | </para> |
---|
| 84 | |
---|
| 85 | <para> |
---|
[1099] | 86 | When using the <literal>external</literal> accounting method, |
---|
| 87 | and if the user is still allowed to print, |
---|
| 88 | the command you specified is launched with the job's data on its |
---|
| 89 | standard input. Your command must print the job's size in number of |
---|
| 90 | pages on a single line on its standard output. This number is then |
---|
| 91 | read by PyKota and used to update the current user's quota information. |
---|
[1101] | 92 | Of course checks are also done like with the <literal>querying</literal> |
---|
| 93 | accounting method, to see if the current job is allowed to be printed or not. |
---|
[1099] | 94 | </para> |
---|
| 95 | |
---|
| 96 | <para> |
---|
[959] | 97 | If a problem occurs, it is logged either to the filter's standard output or to the system logger, depending on |
---|
| 98 | your preferences in <application>PyKota</application>'s configuration file. Also if a print quota is reached |
---|
[1099] | 99 | you may choose if the administrator, the user, both or no-one will receive an email message explaining |
---|
[959] | 100 | the situation and proposing a solution. |
---|
| 101 | </para> |
---|
| 102 | |
---|
[753] | 103 | </chapter> |
---|
| 104 | |
---|
| 105 | <!-- |
---|
| 106 | |
---|
| 107 | $Log$ |
---|
[1101] | 108 | Revision 1.6 2003/07/25 13:10:58 jalet |
---|
| 109 | Improved documentation |
---|
| 110 | |
---|
[1099] | 111 | Revision 1.5 2003/07/25 10:41:29 jalet |
---|
| 112 | Better documentation. |
---|
| 113 | pykotme now displays the current user's account balance. |
---|
| 114 | Some test changed in ldap module. |
---|
| 115 | |
---|
[982] | 116 | Revision 1.4 2003/04/30 20:00:51 jalet |
---|
| 117 | Typo |
---|
| 118 | |
---|
[959] | 119 | Revision 1.3 2003/04/24 21:09:47 jalet |
---|
| 120 | Documentation slightly improved. |
---|
| 121 | |
---|
[865] | 122 | Revision 1.2 2003/03/25 09:32:06 jalet |
---|
| 123 | Improved documentation. |
---|
| 124 | |
---|
[753] | 125 | Revision 1.1 2003/02/08 00:03:35 jalet |
---|
| 126 | Documentation skeleton added |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | --> |
---|