1 | # PyKota |
---|
2 | # -*- coding: ISO-8859-15 -*- |
---|
3 | # |
---|
4 | # PyKota : Print Quotas for CUPS |
---|
5 | # |
---|
6 | # (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet <alet@librelogiciel.com> |
---|
7 | # This program is free software; you can redistribute it and/or modify |
---|
8 | # it under the terms of the GNU General Public License as published by |
---|
9 | # the Free Software Foundation; either version 2 of the License, or |
---|
10 | # (at your option) any later version. |
---|
11 | # |
---|
12 | # This program is distributed in the hope that it will be useful, |
---|
13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | # GNU General Public License for more details. |
---|
16 | # |
---|
17 | # You should have received a copy of the GNU General Public License |
---|
18 | # along with this program; if not, write to the Free Software |
---|
19 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
20 | # |
---|
21 | # $Id$ |
---|
22 | # |
---|
23 | |
---|
24 | """This module contains the definitions of constants used by PyKota.""" |
---|
25 | |
---|
26 | STATUSSTABILIZATIONDELAY = 4.0 # time to sleep between two loops |
---|
27 | STATUSSTABILIZATIONLOOPS = 5 # number of consecutive times the 'idle' status must be seen before we consider it to be stable |
---|
28 | NOPRINTINGMAXDELAY = 60 # The printer must begin to print within 60 seconds by default. |
---|
29 | |
---|
30 | def get(application, varname) : |
---|
31 | """Retrieves the value of a particular printer variable from configuration file, else a constant defined here.""" |
---|
32 | pname = application.PrinterName |
---|
33 | try : |
---|
34 | value = getattr(application.config, "get%(varname)s" % locals())(pname) |
---|
35 | if value is None : |
---|
36 | raise TypeError # Use hardcoded value |
---|
37 | except (TypeError, AttributeError) : # NB : AttributeError in testing mode because I'm lazy ! |
---|
38 | value = globals().get(varname.upper()) |
---|
39 | application.logdebug("No value defined for %(varname)s for printer %(pname)s, using %(value)s." % locals()) |
---|
40 | return value |
---|