88 | | def checkUserPQuota(self, username, printername) : |
89 | | # TODO : this doesn't work as expected wrt dates |
90 | | # TODO : GRACEDELAY should come from the configuration file |
91 | | # TODO : move this into the PyKotaTool class |
92 | | now = DateTime.now() |
93 | | quota = self.getUserPQuota(username, printername) |
94 | | pagecounter = quota["pagecounter"] |
95 | | softlimit = quota["softlimit"] |
96 | | hardlimit = quota["hardlimit"] |
97 | | datelimit = quota["datelimit"] |
98 | | if datelimit : |
99 | | datelimit = DateTime.DateTime(datelimit) # TODO : check this ! |
100 | | if softlimit is not None : |
101 | | if pagecounter < softlimit : |
102 | | action = "ALLOW" |
103 | | elif hardlimit is not None : |
104 | | if softlimit <= pagecounter < hardlimit : |
105 | | if datelimit is None : |
106 | | self.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)))) |
107 | | datelimit = now |
108 | | if (now - datelimit) <= GRACEDELAY : |
109 | | action = "WARN" |
110 | | else : |
111 | | action = "DENY" |
112 | | else : |
113 | | action = "DENY" |
114 | | else : |
115 | | action = "DENY" |
116 | | else : |
117 | | action = "ALLOW" |
118 | | return (action, (hardlimit - pagecounter), datelimit) |
119 | | |