#! /usr/bin/python
# -*- coding: utf-8 -*-
# PyKota Print Quotes generator
#
# PyKota - Print Quotas for CUPS
#
# (c) 2003-2013 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 3 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, see .
#
# $Id$
#
#
import sys
import os
import cgi
import urllib
import cStringIO
from xml.sax import saxutils
import pykota.appinit
from pykota import version, utils
from pykota.tool import PyKotaTool
from pykota.errors import PyKotaToolError
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)) \
or (upquota.MaxJobSize and (jobsize > upquota.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 += "