- Timestamp:
- 03/07/03 23:56:14 (22 years ago)
- Location:
- pykota/trunk/pykota
- Files:
-
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r825 r834 15 15 # 16 16 # $Log$ 17 # Revision 1.25 2003/03/07 22:56:14 jalet 18 # 0.99 is out with some bug fixes. 19 # 17 20 # Revision 1.24 2003/02/27 23:48:41 jalet 18 21 # Correctly maps PyKota's log levels to syslog log levels … … 254 257 policy = self.config.getPrinterPolicy(printername) 255 258 if policy in [None, "ALLOW"] : 256 action = " ALLOW"259 action = "POLICY_ALLOW" 257 260 else : 258 action = " DENY"261 action = "POLICY_DENY" 259 262 self.logger.log_message(_("Unable to match user %s on printer %s, applying default policy (%s)") % (username, printername, action)) 260 return (action, None, None)261 263 else : 262 264 pagecounter = quota["pagecounter"] … … 264 266 hardlimit = quota["hardlimit"] 265 267 datelimit = quota["datelimit"] 266 if datelimit is not None :267 datelimit = DateTime.ISO.ParseDateTime(datelimit)268 268 if softlimit is not None : 269 269 if pagecounter < softlimit : 270 270 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 : 280 288 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 : 282 295 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 288 300 289 301 def warnGroupPQuota(self, username, printername=None) : … … 297 309 admin = self.config.getAdmin(pname) 298 310 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:] 300 314 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) 307 319 elif action == "WARN" : 308 320 adminmessage = _("Print Quota soft limit exceeded for user %s on printer %s") % (username, pname) -
pykota/trunk/pykota/version.py
r827 r834 15 15 # 16 16 17 __version__ = "0.9 8-unofficial"17 __version__ = "0.99-unofficial" 18 18 19 19 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS."""