Changeset 1077

Show
Ignore:
Timestamp:
07/08/03 21:43:51 (21 years ago)
Author:
jalet
Message:

Configurable warning messages.
Poor man's treshold value added.

Location:
pykota/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/conf/pykota.conf.sample

    r1055 r1077  
    153153gracedelay: 7 
    154154 
     155# 
     156# Poor man's threshold 
     157# If account balance reaches below this amount, 
     158# a warning message is sent by email 
     159# 
     160# If unset, default poor man's threshold is 1.0. 
     161# This option can only appear in the global section 
     162poorman: 2.0 
     163 
     164# Poor man's warning message 
     165# The warning message that is sent if the "poorman" value is reached 
     166# Again this must appear in the global section 
     167poorwarn: Your Print Quota account balance is low.  
     168 Soon you'll not be allowed to print anymore. 
     169 
     170# Soft limit reached warning message 
     171# The warning message that is sent if the soft quota limit is reached 
     172# May appear either globally or on a per-printer basis 
     173softwarn: Your Print Quota Soft Limit is reached. 
     174 This means that you may still be allowed to print for some 
     175 time, but you must contact your administrator to purchase  
     176 more print quota. 
     177  
     178# Hard limit reached error message 
     179# The error message that is sent if the hard quota limit is reached 
     180# May appear either globally or on a per-printer basis 
     181hardwarn: Your Print Quota Hard Limit is reached. 
     182 This means that you are not allowed to print anymore. 
     183 Please contact your administrator at root@localhost 
     184 as soon as possible to solve the problem. 
     185 
    155186# one section per printer, or no other section at all if all options  
    156187# are defined globally. 
  • pykota/trunk/NEWS

    r1072 r1077  
    2222PyKota NEWS : 
    2323 
     24    - 1.14alpha1 : 
     25     
     26        - Poor man's treshold included : users with a low account 
     27          balance (below 1.0 by default, configurable) are sent 
     28          a warning message. 
     29           
     30        - All warning messages to users are now configurable.   
     31          NB : Warning messages to the administrator are not. 
     32         
    2433    - 1.13 : 
    2534     
  • pykota/trunk/po/en/pykota.po

    r1058 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.31  2003/07/08 19:43:50  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.30  2003/07/03 11:38:44  jalet 
    2428# Translations for pykotme added 
     
    325329msgstr "" 
    326330 
     331msgid "Print Quota soft limit exceeded for group %s on printer %s" 
     332msgstr "" 
     333 
     334msgid "Totals may be inaccurate if some users are members of several groups." 
     335msgstr "" 
     336 
     337msgid "Price per job: %.3f" 
     338msgstr "" 
     339 
     340msgid "Price per page: %.3f" 
     341msgstr "" 
     342 
     343msgid "Group %s not found in the PyKota Storage." 
     344msgstr "" 
     345 
     346msgid "Unsupported accounter backend %s" 
     347msgstr "" 
     348 
     349msgid "Option accounter in section %s only supports values in %s" 
     350msgstr "" 
     351 
     352msgid "Option requester for printer %s was not set" 
     353msgstr "" 
     354 
     355msgid "Using the 'stupid' accounting method is unreliable." 
     356msgstr "" 
     357 
     358msgid "Invalid external accounter %s for printer %s" 
     359msgstr "" 
     360 
     361msgid "Unable to compute job size with external accounter %s" 
     362msgstr "" 
     363 
     364msgid "Search for %s(%s) from %s(scope=%s) returned no answer." 
     365msgstr "" 
     366 
     367msgid "Problem adding LDAP entry (%s, %s)" 
     368msgstr "" 
     369 
     370msgid "Problem modifying LDAP entry (%s, %s)" 
     371msgstr "" 
     372 
     373msgid "Problem deleting LDAP entry (%s)" 
     374msgstr "" 
     375 
     376msgid "Impossible to add printer %s" 
     377msgstr "" 
     378 
     379msgid "Prototype object %s not found in Quota Storage." 
     380msgstr "" 
     381 
     382msgid "Impossible to send mail to %s, error %s : %s" 
     383msgstr "" 
     384 
     385msgid "Unsupported reporter backend %s" 
     386msgstr "" 
     387 
     388msgid "Unable to compute size of %s in number of pages.\n" 
     389msgstr "" 
     390 
     391msgid "Job size : %i pages"     
     392msgstr "" 
     393 
     394msgid "Cost on printer %s : %.2f" 
     395msgstr "" 
     396 
     397msgid "Invalid poor man's treshold %s" 
     398msgstr "" 
     399 
    327400msgid "" 
    328 "You are not allowed to print anymore because\n" 
    329 "your group Print Quota is exceeded on printer %s." 
    330 msgstr "" 
    331  
    332 msgid "Print Quota soft limit exceeded for group %s on printer %s" 
    333 msgstr "" 
    334  
    335 msgid "" 
    336 "You will soon be forbidden to print anymore because\n" 
    337 "your group Print Quota is almost reached on printer %s." 
    338 msgstr "" 
    339  
    340 msgid "Totals may be inaccurate if some users are members of several groups." 
    341 msgstr "" 
    342  
    343 msgid "Price per job: %.3f" 
    344 msgstr "" 
    345  
    346 msgid "Price per page: %.3f" 
    347 msgstr "" 
    348  
    349 msgid "Group %s not found in the PyKota Storage." 
    350 msgstr "" 
    351  
    352 msgid "Unsupported accounter backend %s" 
    353 msgstr "" 
    354  
    355 msgid "Option accounter in section %s only supports values in %s" 
    356 msgstr "" 
    357  
    358 msgid "Option requester for printer %s was not set" 
    359 msgstr "" 
    360  
    361 msgid "Using the 'stupid' accounting method is unreliable." 
    362 msgstr "" 
    363  
    364 msgid "Invalid external accounter %s for printer %s" 
    365 msgstr "" 
    366  
    367 msgid "Unable to compute job size with external accounter %s" 
    368 msgstr "" 
    369  
    370 msgid "Search for %s(%s) from %s(scope=%s) returned no answer." 
    371 msgstr "" 
    372  
    373 msgid "Problem adding LDAP entry (%s, %s)" 
    374 msgstr "" 
    375  
    376 msgid "Problem modifying LDAP entry (%s, %s)" 
    377 msgstr "" 
    378  
    379 msgid "Problem deleting LDAP entry (%s)" 
    380 msgstr "" 
    381  
    382 msgid "Impossible to add printer %s" 
    383 msgstr "" 
    384  
    385 msgid "Prototype object %s not found in Quota Storage." 
    386 msgstr "" 
    387  
    388 msgid "Impossible to send mail to %s, error %s : %s" 
    389 msgstr "" 
    390  
    391 msgid "Unsupported reporter backend %s" 
    392 msgstr "" 
    393  
    394 msgid "Unable to compute size of %s in number of pages.\n" 
    395 msgstr "" 
    396  
    397 msgid "Job size : %i pages"     
    398 msgstr "" 
    399  
    400 msgid "Cost on printer %s : %.2f" 
    401 msgstr "" 
     401"Your Print Quota account balance is Low.\n" 
     402"Soon you'll not be allowed to print anymore.\n" 
     403"Please contact the Print Quota Administrator to solve the problem." 
     404msgstr "" 
     405 
     406msgid "Print Quota Low" 
     407msgstr "" 
     408 
  • pykota/trunk/po/fr/pykota.po

    r1058 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.30  2003/07/08 19:43:51  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.29  2003/07/03 11:38:44  jalet 
    2428# Translations for pykotme added 
     
    334338msgstr "D�ssement de Quota d'impression pour le groupe %s sur l'imprimante %s" 
    335339 
    336 msgid "" 
    337 "You are not allowed to print anymore because\n" 
    338 "your group Print Quota is exceeded on printer %s." 
    339 msgstr "" 
    340 "Vous n'�s plus autoris� imprimer car\n" 
    341 "le Quota d'Impression de votre groupe est d�ss�ur l'imprimante %s." 
    342  
    343340msgid "Print Quota soft limit exceeded for group %s on printer %s" 
    344341msgstr "Limite souple de Quota d'Impression d�ss�pour le groupe %s sur l'imprimante %s" 
    345  
    346 msgid "" 
    347 "You will soon be forbidden to print anymore because\n" 
    348 "your group Print Quota is almost reached on printer %s." 
    349 msgstr "" 
    350 "Vous n'aurez bient�lus le droit d'imprimer car\n" 
    351 "le Quota d'Impression de votre groupe sur l'imprimante %s est presque atteint." 
    352342 
    353343msgid "Totals may be inaccurate if some users are members of several groups." 
     
    411401msgid "Cost on printer %s : %.2f" 
    412402msgstr "Co�r l'imprimante %s : %.2f" 
     403 
     404msgid "Invalid poor man's treshold %s" 
     405msgstr "Valeur 'pauvre homme' %s invalide" 
     406 
     407msgid "" 
     408"Your Print Quota account balance is Low.\n" 
     409"Soon you'll not be allowed to print anymore.\n" 
     410"Please contact the Print Quota Administrator to solve the problem." 
     411msgstr "" 
     412"Le montant de votre compte d'impression est Bas.\n" 
     413"Bient�ous ne serez plus autoris�) �mprimer.\n" 
     414"Merci de contacter l'Administrateur de Quota d'Impression pour r�udre ce probl�." 
     415 
     416msgid "Print Quota Low" 
     417msgstr "Quota d'Impression Bas" 
     418 
  • pykota/trunk/po/pykota.pot

    r1058 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.31  2003/07/08 19:43:50  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.30  2003/07/03 11:38:43  jalet 
    2428# Translations for pykotme added 
     
    325329msgstr "" 
    326330 
     331msgid "Print Quota soft limit exceeded for group %s on printer %s" 
     332msgstr "" 
     333 
     334msgid "Totals may be inaccurate if some users are members of several groups." 
     335msgstr "" 
     336 
     337msgid "Price per job: %.3f" 
     338msgstr "" 
     339 
     340msgid "Price per page: %.3f" 
     341msgstr "" 
     342 
     343msgid "Group %s not found in the PyKota Storage." 
     344msgstr "" 
     345 
     346msgid "Unsupported accounter backend %s" 
     347msgstr "" 
     348 
     349msgid "Option accounter in section %s only supports values in %s" 
     350msgstr "" 
     351 
     352msgid "Option requester for printer %s was not set" 
     353msgstr "" 
     354 
     355msgid "Using the 'stupid' accounting method is unreliable." 
     356msgstr "" 
     357 
     358msgid "Invalid external accounter %s for printer %s" 
     359msgstr "" 
     360 
     361msgid "Unable to compute job size with external accounter %s" 
     362msgstr "" 
     363 
     364msgid "Search for %s(%s) from %s(scope=%s) returned no answer." 
     365msgstr "" 
     366 
     367msgid "Problem adding LDAP entry (%s, %s)" 
     368msgstr "" 
     369 
     370msgid "Problem modifying LDAP entry (%s, %s)" 
     371msgstr "" 
     372 
     373msgid "Problem deleting LDAP entry (%s)" 
     374msgstr "" 
     375 
     376msgid "Impossible to add printer %s" 
     377msgstr "" 
     378 
     379msgid "Prototype object %s not found in Quota Storage." 
     380msgstr "" 
     381 
     382msgid "Impossible to send mail to %s, error %s : %s" 
     383msgstr "" 
     384 
     385msgid "Unsupported reporter backend %s" 
     386msgstr "" 
     387 
     388msgid "Unable to compute size of %s in number of pages.\n" 
     389msgstr "" 
     390 
     391msgid "Job size : %i pages"     
     392msgstr "" 
     393 
     394msgid "Cost on printer %s : %.2f" 
     395msgstr "" 
     396 
     397msgid "Invalid poor man's treshold %s" 
     398msgstr "" 
     399 
    327400msgid "" 
    328 "You are not allowed to print anymore because\n" 
    329 "your group Print Quota is exceeded on printer %s." 
    330 msgstr "" 
    331  
    332 msgid "Print Quota soft limit exceeded for group %s on printer %s" 
    333 msgstr "" 
    334  
    335 msgid "" 
    336 "You will soon be forbidden to print anymore because\n" 
    337 "your group Print Quota is almost reached on printer %s." 
    338 msgstr "" 
    339  
    340 msgid "Totals may be inaccurate if some users are members of several groups." 
    341 msgstr "" 
    342  
    343 msgid "Price per job: %.3f" 
    344 msgstr "" 
    345  
    346 msgid "Price per page: %.3f" 
    347 msgstr "" 
    348  
    349 msgid "Group %s not found in the PyKota Storage." 
    350 msgstr "" 
    351  
    352 msgid "Unsupported accounter backend %s" 
    353 msgstr "" 
    354  
    355 msgid "Option accounter in section %s only supports values in %s" 
    356 msgstr "" 
    357  
    358 msgid "Option requester for printer %s was not set" 
    359 msgstr "" 
    360  
    361 msgid "Using the 'stupid' accounting method is unreliable." 
    362 msgstr "" 
    363  
    364 msgid "Invalid external accounter %s for printer %s" 
    365 msgstr "" 
    366  
    367 msgid "Unable to compute job size with external accounter %s" 
    368 msgstr "" 
    369  
    370 msgid "Search for %s(%s) from %s(scope=%s) returned no answer." 
    371 msgstr "" 
    372  
    373 msgid "Problem adding LDAP entry (%s, %s)" 
    374 msgstr "" 
    375  
    376 msgid "Problem modifying LDAP entry (%s, %s)" 
    377 msgstr "" 
    378  
    379 msgid "Problem deleting LDAP entry (%s)" 
    380 msgstr "" 
    381  
    382 msgid "Impossible to add printer %s" 
    383 msgstr "" 
    384  
    385 msgid "Prototype object %s not found in Quota Storage." 
    386 msgstr "" 
    387  
    388 msgid "Impossible to send mail to %s, error %s : %s" 
    389 msgstr "" 
    390  
    391 msgid "Unsupported reporter backend %s" 
    392 msgstr "" 
    393  
    394 msgid "Unable to compute size of %s in number of pages.\n" 
    395 msgstr "" 
    396  
    397 msgid "Job size : %i pages"     
    398 msgstr "" 
    399  
    400 msgid "Cost on printer %s : %.2f" 
    401 msgstr "" 
     401"Your Print Quota account balance is Low.\n" 
     402"Soon you'll not be allowed to print anymore.\n" 
     403"Please contact the Print Quota Administrator to solve the problem." 
     404msgstr "" 
     405 
     406msgid "Print Quota Low" 
     407msgstr "" 
     408 
  • pykota/trunk/pykota/config.py

    r1068 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.32  2003/07/08 19:43:51  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.31  2003/07/07 11:49:24  jalet 
    2428# Lots of small fixes with the help of PyChecker 
     
    327331        try : 
    328332            return int(gd) 
    329         except ValueError :     
     333        except (TypeError, ValueError) :     
    330334            raise PyKotaConfigError, _("Invalid grace delay %s") % gd 
     335             
     336    def getPoorMan(self) :     
     337        """Returns the poor man's treshold.""" 
     338        try : 
     339            pm = self.getGlobalOption("poorman") 
     340        except PyKotaConfigError :     
     341            pm = 1.0 
     342        try : 
     343            return float(pm) 
     344        except (TypeError, ValueError) :     
     345            raise PyKotaConfigError, _("Invalid poor man's treshold %s") % pm 
     346             
     347    def getPoorWarn(self) :     
     348        """Returns the poor man's warning message.""" 
     349        try : 
     350            return self.getGlobalOption("poorwarn") 
     351        except PyKotaConfigError :     
     352            return _("Your Print Quota account balance is Low.\nSoon you'll not be allowed to print anymore.\nPlease contact the Print Quota Administrator to solve the problem.") 
     353             
     354    def getHardWarn(self, printer) :     
     355        """Returns the hard limit error message.""" 
     356        try : 
     357            return self.getPrinterOption(printer, "hardwarn") 
     358        except PyKotaConfigError :     
     359            return _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % printer 
     360             
     361    def getSoftWarn(self, printer) :     
     362        """Returns the soft limit error message.""" 
     363        try : 
     364            return self.getPrinterOption(printer, "softwarn") 
     365        except PyKotaConfigError :     
     366            return _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % printer 
    331367             
    332368    def getDebug(self) :           
  • pykota/trunk/pykota/tool.py

    r1068 r1077  
    2121# 
    2222# $Log$ 
     23# Revision 1.45  2003/07/08 19:43:51  jalet 
     24# Configurable warning messages. 
     25# Poor man's treshold value added. 
     26# 
    2327# Revision 1.44  2003/07/07 11:49:24  jalet 
    2428# Lots of small fixes with the help of PyChecker 
     
    337341        printer = grouppquota.Printer 
    338342        if group.LimitBy and (group.LimitBy.lower() == "balance") :  
    339             # TODO : there's no warning (no account balance soft limit) 
    340             if float(group.AccountBalance) <= 0.0 : 
     343            if group.AccountBalance <= 0.0 : 
    341344                action = "DENY" 
     345            elif group.AccountBalance <= self.config.getPoorMan() :     
     346                action = "WARN" 
    342347            else :     
    343348                action = "ALLOW" 
     
    402407                self.logger.log_message(_("Unable to find user %s's account balance, applying default policy (%s) for printer %s") % (user.Name, action, printer.Name)) 
    403408            else :     
    404                 # TODO : there's no warning (no account balance soft limit) 
    405                 if float(user.AccountBalance or 0.0) <= 0.0 : 
     409                val = float(user.AccountBalance or 0.0) 
     410                if val <= 0.0 : 
    406411                    action = "DENY" 
     412                elif val <= self.config.getPoorMan() :     
     413                    action = "WARN" 
    407414                else :     
    408415                    action = "ALLOW" 
     
    470477            for user in self.storage.getGroupMembers(group) : 
    471478                if mailto in [ "BOTH", "USER" ] : 
    472                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour group Print Quota is exceeded on printer %s.") % printer.Name) 
     479                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    473480        elif action == "WARN" :     
    474481            adminmessage = _("Print Quota soft limit exceeded for group %s on printer %s") % (group.Name, printer.Name) 
     
    476483            if mailto in [ "BOTH", "ADMIN" ] : 
    477484                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     485            if group.LimitBy and (group.LimitBy.lower() == "balance") :  
     486                message = self.config.getPoorWarn() 
     487            else :      
     488                message = self.config.getSoftWarn(printer.Name) 
    478489            for user in self.storage.getGroupMembers(group) : 
    479490                if mailto in [ "BOTH", "USER" ] : 
    480                     self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour group Print Quota is almost reached on printer %s.") % printer.Name) 
     491                    self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), message) 
    481492        return action         
    482493         
     
    495506            self.logger.log_message(adminmessage) 
    496507            if mailto in [ "BOTH", "USER" ] : 
    497                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % printer.Name) 
     508                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), self.config.getHardWarn(printer.Name)) 
    498509            if mailto in [ "BOTH", "ADMIN" ] : 
    499510                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     
    502513            self.logger.log_message(adminmessage) 
    503514            if mailto in [ "BOTH", "USER" ] : 
    504                 self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Exceeded"), _("You will soon be forbidden to print anymore because\nyour Print Quota is almost reached on printer %s.") % printer.Name) 
     515                if user.LimitBy and (user.LimitBy.lower() == "balance") :  
     516                    message = self.config.getPoorWarn() 
     517                else :      
     518                    message = self.config.getSoftWarn(printer.Name) 
     519                self.sendMessageToUser(admin, adminmail, user.Name, _("Print Quota Low"), message) 
    505520            if mailto in [ "BOTH", "ADMIN" ] : 
    506521                self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
  • pykota/trunk/pykota/version.py

    r1068 r1077  
    2121# 
    2222 
    23 __version__ = "1.13_unofficial" 
     23__version__ = "1.14alpha1_unofficial" 
    2424 
    2525__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""