Changeset 834 for pykota/trunk

Show
Ignore:
Timestamp:
03/07/03 23:56:14 (22 years ago)
Author:
jalet
Message:

0.99 is out with some bug fixes.

Location:
pykota/trunk/pykota
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r825 r834  
    1515# 
    1616# $Log$ 
     17# Revision 1.25  2003/03/07 22:56:14  jalet 
     18# 0.99 is out with some bug fixes. 
     19# 
    1720# Revision 1.24  2003/02/27 23:48:41  jalet 
    1821# Correctly maps PyKota's log levels to syslog log levels 
     
    254257            policy = self.config.getPrinterPolicy(printername) 
    255258            if policy in [None, "ALLOW"] : 
    256                 action = "ALLOW" 
     259                action = "POLICY_ALLOW" 
    257260            else :     
    258                 action = "DENY" 
     261                action = "POLICY_DENY" 
    259262            self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action)) 
    260             return (action, None, None) 
    261263        else :     
    262264            pagecounter = quota["pagecounter"] 
     
    264266            hardlimit = quota["hardlimit"] 
    265267            datelimit = quota["datelimit"] 
    266             if datelimit is not None : 
    267                 datelimit = DateTime.ISO.ParseDateTime(datelimit) 
    268268            if softlimit is not None : 
    269269                if pagecounter < softlimit : 
    270270                    action = "ALLOW" 
    271                 elif hardlimit is not None : 
    272                     if softlimit <= pagecounter < hardlimit :     
    273                         now = DateTime.now() 
    274                         if datelimit is None : 
    275                             datelimit = now + self.config.getGraceDelay(printername) 
    276                             self.storage.setDateLimit(username, printername, datelimit) 
    277                         if now < datelimit : 
    278                             action = "WARN" 
    279                         else :     
     271                else :     
     272                    if hardlimit is None : 
     273                        # only a soft limit, this is equivalent to having only a hard limit 
     274                        action = "DENY" 
     275                    else :     
     276                        if softlimit <= pagecounter < hardlimit :     
     277                            now = DateTime.now() 
     278                            if datelimit is not None : 
     279                                datelimit = DateTime.ISO.ParseDateTime(datelimit) 
     280                            else : 
     281                                datelimit = now + self.config.getGraceDelay(printername) 
     282                                self.storage.setDateLimit(username, printername, datelimit) 
     283                            if now < datelimit : 
     284                                action = "WARN" 
     285                            else :     
     286                                action = "DENY" 
     287                        else :          
    280288                            action = "DENY" 
    281                     else :          
     289            else :         
     290                if hardlimit is not None : 
     291                    # no soft limit, only a hard one. 
     292                    if pagecounter < hardlimit : 
     293                        action = "ALLOW" 
     294                    else :       
    282295                        action = "DENY" 
    283                 else :         
    284                     action = "DENY" 
    285             else :         
    286                 action = "ALLOW" 
    287             return (action, (hardlimit - pagecounter), datelimit) 
     296                else : 
     297                    # Both are unset, no quota 
     298                    action = "ALLOW" 
     299        return action 
    288300     
    289301    def warnGroupPQuota(self, username, printername=None) : 
     
    297309        admin = self.config.getAdmin(pname) 
    298310        adminmail = self.config.getAdminMail(pname) 
    299         (action, grace, gracedate) = self.checkUserPQuota(username, pname) 
     311        action = self.checkUserPQuota(username, pname) 
     312        if action.startswith("POLICY_") : 
     313            action = action[7:] 
    300314        if action == "DENY" : 
    301             if (grace is not None) and (gracedate is not None) : 
    302                 # only when both user and printer are known 
    303                 adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname) 
    304                 self.logger.log_message(adminmessage) 
    305                 self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % pname) 
    306                 self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
     315            adminmessage = _("Print Quota exceeded for user %s on printer %s") % (username, pname) 
     316            self.logger.log_message(adminmessage) 
     317            self.sendMessageToUser(admin, adminmail, username, _("Print Quota Exceeded"), _("You are not allowed to print anymore because\nyour Print Quota is exceeded on printer %s.") % pname) 
     318            self.sendMessageToAdmin(adminmail, _("Print Quota"), adminmessage) 
    307319        elif action == "WARN" :     
    308320            adminmessage = _("Print Quota soft limit exceeded for user %s on printer %s") % (username, pname) 
  • pykota/trunk/pykota/version.py

    r827 r834  
    1515# 
    1616 
    17 __version__ = "0.98-unofficial" 
     17__version__ = "0.99-unofficial" 
    1818 
    1919__doc__ = """PyKota : a complete Printing Quota Solution for CUPS."""