[753] | 1 | <!-- $Id$ --> |
---|
| 2 | |
---|
| 3 | <chapter> |
---|
[1187] | 4 | <title id="filter">PyKota's internals</title> |
---|
[865] | 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 |
---|
[1168] | 34 | prove to be unreliable depending on the drivers used or if a paper jam occurs for example. |
---|
[865] | 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> |
---|
[1187] | 51 | Currently with a <application>CUPS</application> backend, the <application>pykota</application> filter is |
---|
| 52 | deprecated. You have to use the <application>cupspykota</application> CUPS backend instead. |
---|
| 53 | This CUPS backend ensures that jobs can't bypass the filtering mechanism, so you can use |
---|
| 54 | any printer with any driver and any command line option, and you can be sure that your |
---|
| 55 | print job will be correctly accounted for. |
---|
[865] | 56 | </para> |
---|
| 57 | |
---|
| 58 | <para> |
---|
[959] | 59 | When used with an <application>LPRng</application> backend, the accounting filter is not defined the same way |
---|
| 60 | input filters are, so the problem described above doesn't exist, and <application>PyKota</application> |
---|
[1101] | 61 | may work with non-postscript printers, provided they can report their page counter and you know how to retrieve |
---|
| 62 | it. |
---|
[865] | 63 | </para> |
---|
| 64 | |
---|
[959] | 65 | <para> |
---|
[1187] | 66 | When you submit a print job, <application>cupspykota</application> (with CUPS) or <application>pykota</application> (with LPRng) is automatically launched by your printing system, |
---|
[959] | 67 | so it has to detect which system you are using (<application>CUPS</application> or <application>LPRng</application>) |
---|
| 68 | and behave like if it was specifically designed for your printing system. Fortunately there's not a lot |
---|
| 69 | of differences, the more important one is the exit codes used to tell the printing environment if a job |
---|
| 70 | has to be accepted or rejected. |
---|
| 71 | </para> |
---|
| 72 | |
---|
| 73 | <para> |
---|
[1475] | 74 | When using the <literal>hardware</literal> accounting method, |
---|
[1187] | 75 | <application>pykota</application> asks the printer for its internal page counter, reads from the Quota DataBase the internal |
---|
[959] | 76 | page counter for this printer when the previous job was launched, computes the difference, and report it as the |
---|
| 77 | previous job's size in the Quota DataBase. It then updates the last user's print quota and account balance, and |
---|
[1101] | 78 | warn him if he is over quota or if his account balance is below 0. Finally it checks if the user who launched the |
---|
[1168] | 79 | current job is below or above his print quota, and either allows or denies the job's datas to pass to the underlying |
---|
[1187] | 80 | layer (the printer itself). The <application>cupspykota</application> CUPS backend on the other hand, |
---|
| 81 | asks the printer for its internal page counter at the start and at the end of the print job, and |
---|
| 82 | computes the values' difference so accounting is done immediately. This way it doesn't let open a window for abuse in the case |
---|
| 83 | several printers are managed. That's why the use of <application>cupspykota</application> |
---|
[1386] | 84 | instead of <application>pykota</application> is recommended with CUPS. |
---|
[959] | 85 | </para> |
---|
| 86 | |
---|
| 87 | <para> |
---|
[1475] | 88 | When using the <literal>software</literal> accounting method, |
---|
[1099] | 89 | and if the user is still allowed to print, |
---|
| 90 | the command you specified is launched with the job's data on its |
---|
| 91 | standard input. Your command must print the job's size in number of |
---|
| 92 | pages on a single line on its standard output. This number is then |
---|
| 93 | read by PyKota and used to update the current user's quota information. |
---|
[1475] | 94 | Of course checks are also done like with the <literal>hardware</literal> |
---|
[1101] | 95 | accounting method, to see if the current job is allowed to be printed or not. |
---|
[1099] | 96 | </para> |
---|
| 97 | |
---|
| 98 | <para> |
---|
[959] | 99 | If a problem occurs, it is logged either to the filter's standard output or to the system logger, depending on |
---|
[1168] | 100 | your preferences in <application>PyKota</application>'s configuration files. Also if a print quota is reached |
---|
[1099] | 101 | you may choose if the administrator, the user, both or no-one will receive an email message explaining |
---|
[959] | 102 | the situation and proposing a solution. |
---|
| 103 | </para> |
---|
| 104 | |
---|
[753] | 105 | </chapter> |
---|
| 106 | |
---|
| 107 | <!-- |
---|
| 108 | |
---|
| 109 | $Log$ |
---|
[1475] | 110 | Revision 1.10 2004/05/13 13:59:28 jalet |
---|
| 111 | Code simplifications |
---|
| 112 | |
---|
[1386] | 113 | Revision 1.9 2004/03/03 19:35:36 jalet |
---|
| 114 | Spelling problem. Thanks to Jurandy Martins |
---|
| 115 | |
---|
[1187] | 116 | Revision 1.8 2003/11/15 14:59:53 jalet |
---|
| 117 | Documentation wrt the new CUPS backend. |
---|
| 118 | |
---|
[1168] | 119 | Revision 1.7 2003/10/14 20:26:53 jalet |
---|
| 120 | Better documentation. |
---|
| 121 | 1.15 is out ! |
---|
| 122 | |
---|
[1101] | 123 | Revision 1.6 2003/07/25 13:10:58 jalet |
---|
| 124 | Improved documentation |
---|
| 125 | |
---|
[1099] | 126 | Revision 1.5 2003/07/25 10:41:29 jalet |
---|
| 127 | Better documentation. |
---|
| 128 | pykotme now displays the current user's account balance. |
---|
| 129 | Some test changed in ldap module. |
---|
| 130 | |
---|
[982] | 131 | Revision 1.4 2003/04/30 20:00:51 jalet |
---|
| 132 | Typo |
---|
| 133 | |
---|
[959] | 134 | Revision 1.3 2003/04/24 21:09:47 jalet |
---|
| 135 | Documentation slightly improved. |
---|
| 136 | |
---|
[865] | 137 | Revision 1.2 2003/03/25 09:32:06 jalet |
---|
| 138 | Improved documentation. |
---|
| 139 | |
---|
[753] | 140 | Revision 1.1 2003/02/08 00:03:35 jalet |
---|
| 141 | Documentation skeleton added |
---|
| 142 | |
---|
| 143 | |
---|
| 144 | --> |
---|