#! /usr/bin/python
# -*- coding: ISO-8859-15 -*-
# PyKota Print Quotes generator
#
# PyKota - Print Quotas for CUPS and LPRng
#
# (c) 2003, 2004, 2005, 2006, 2007 Jerome Alet
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# $Id$
#
#
import sys
import os
import cgi
import urllib
import cStringIO
from pykota import version
from pykota.tool import PyKotaTool, PyKotaToolError
from pykota.cgifuncs import getLanguagePreference, getCharsetPreference
from pkpgpdls import analyzer, pdlparser
header = """Content-type: text/html;charset=%s
%s
" % (_("Job size : %i pages") % jobsize)
remuser = os.environ.get("REMOTE_USER")
# special hack to accomodate mod_auth_ldap Apache module
try :
remuser = remuser.split("=")[1].split(",")[0]
except :
pass
if not remuser :
self.body += "
%s
" % _("The exact cost of a print job can only be determined for a particular user. Please retry while logged-in.")
else :
try :
user = self.storage.getUser(remuser)
if user.Exists :
if user.LimitBy == "noprint" :
self.body += "
%s
" % _("Your account settings forbid you to print at this time.")
else :
for printer in printers :
upquota = self.storage.getUserPQuota(user, printer)
if upquota.Exists :
if printer.MaxJobSize and (jobsize > printer.MaxJobSize) :
msg = _("You are not allowed to print so many pages on printer %s at this time.") % printer.Name
else :
cost = upquota.computeJobPrice(jobsize)
msg = _("Cost on printer %s : %.2f") % (printer.Name, cost)
if printer.PassThrough :
msg = "%s (%s)" % (msg, _("won't be charged, printer is in passthrough mode"))
elif user.LimitBy == "nochange" :
msg = "%s (%s)" % (msg, _("won't be charged, your account is immutable"))
self.body += "