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