Changeset 709

Show
Ignore:
Timestamp:
02/06/03 00:45:09 (21 years ago)
Author:
jalet
Message:

Better DateTime? manipulation wrt grace delay

Files:
1 modified

Legend:

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

    r708 r709  
    1515# 
    1616# $Log$ 
     17# Revision 1.5  2003/02/05 23:45:09  jalet 
     18# Better DateTime manipulation wrt grace delay 
     19# 
    1720# Revision 1.4  2003/02/05 23:26:22  jalet 
    1821# Incorrect handling of grace delay 
     
    8689        hardlimit = quota["hardlimit"] 
    8790        datelimit = quota["datelimit"] 
    88         if datelimit : 
    89             datelimit = DateTime.DateTime(datelimit)    # TODO : check this ! 
     91        if datelimit is not None : 
     92            datelimit = DateTime.ISO.ParseDateTime(datelimit) 
    9093        if softlimit is not None : 
    9194            if pagecounter < softlimit : 
    9295                action = "ALLOW" 
    9396            elif hardlimit is not None : 
     97                 gracedelay = self.config.getGraceDelay() 
    9498                 if softlimit <= pagecounter < hardlimit :     
    9599                     if datelimit is None : 
    96                          self.storage.doQuery("UPDATE userpquota SET datelimit=%s::DATETIME WHERE userid=%s AND printerid=%s;" % (self.doQuote("%04i-%02i-%02i %02i:%02i" % (now.year, now.month, now.day, now.hour, now.minute)), self.doQuote(self.getUserId(username)), self.doQuote(self.getPrinterId(printername)))) 
    97                          datelimit = now 
    98                      if (now - datelimit) <= self.config.getGraceDelay() : 
     100                         datelimit = now + gracedelay 
     101                         self.storage.doQuery("UPDATE userpquota SET datelimit=%s::DATETIME WHERE userid=%s AND printerid=%s;" % (self.doQuote("%04i-%02i-%02i %02i:%02i:%02i" % (datelimit.year, datelimit.month, datelimit.day, datelimit.hour, datelimit.minute, datelimit.second)), self.doQuote(self.getUserId(username)), self.doQuote(self.getPrinterId(printername)))) 
     102                     if (now + gracedelay) < datelimit : 
    99103                         action = "WARN" 
    100104                     else :     
     
    110114    def warnQuotaPrinter(self, username) : 
    111115        """Checks a user quota and send him a message if quota is exceeded on current printer.""" 
    112         (action, grace, gracedate) = self.storage.checkUserPQuota(username, self.printername) 
     116        (action, grace, gracedate) = self.checkUserPQuota(username, self.printername) 
    113117        if action == "DENY" : 
    114118            adminmessage = "Print Quota exceeded for user %s on printer %s" % (username, self.printername)