Changeset 768
- Timestamp:
- 02/08/03 23:39:46 (22 years ago)
- Location:
- pykota/trunk
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r767 r768 17 17 # 18 18 # $Log$ 19 # Revision 1.16 2003/02/08 22:39:46 jalet 20 # --reset command line option added 21 # 19 22 # Revision 1.15 2003/02/08 22:20:01 jalet 20 23 # Clarification on why we don't check with /etc/passwd to see if the user … … 98 101 -p | --prototype u|g Uses user u or group g as a prototype to set 99 102 print quotas 103 104 -r | --reset Resets the printed page counter for the user 105 or group to zero. The life time page counter 106 is kept unchanged. 100 107 101 108 -S | --softlimit sl Sets the quota soft limit to sl pages. … … 223 230 if options["users"] : 224 231 self.storage.setUserPQuota(name, printer, softlimit, hardlimit) 232 if options["reset"] : 233 self.storage.resetUserPQuota(name, printer) 225 234 else : 226 235 self.storage.setGroupPQuota(name, printer, softlimit, hardlimit) 236 if options["reset"] : 237 self.storage.resetGroupPQuota(name, printer) 227 238 228 239 if __name__ == "__main__" : … … 233 244 "printer" : "*", \ 234 245 } 235 short_options = "vhaug p:P:S:H:"236 long_options = ["help", "version", "add", "users", "groups", " prototype=", "printer=", "softlimit=", "hardlimit="]246 short_options = "vhaugrp:P:S:H:" 247 long_options = ["help", "version", "add", "users", "groups", "reset", "prototype=", "printer=", "softlimit=", "hardlimit="] 237 248 238 249 # Initializes the command line tool … … 252 263 options["softlimit"] = options["S"] or options["softlimit"] 253 264 options["hardlimit"] = options["H"] or options["hardlimit"] 265 options["reset"] = options["r"] or options["reset"] 254 266 255 267 if options["help"] : -
pykota/trunk/pykota/storage.py
r759 r768 15 15 # 16 16 # $Log$ 17 # Revision 1.5 2003/02/08 22:39:46 jalet 18 # --reset command line option added 19 # 17 20 # Revision 1.4 2003/02/08 09:59:59 jalet 18 21 # Added preliminary base class for all storages … … 66 69 67 70 def addUserPQuota(self, username, printername) : 68 """ Adds a tuple (user, printer) to the Quota Storage, both are also added individuallyif needed."""71 """Initializes a user print quota on a printer, adds the printer and the user to the quota storage if needed.""" 69 72 pass 70 73 … … 79 82 def setUserPQuota(self, username, printername, softlimit, hardlimit) : 80 83 """Sets soft and hard limits for a user quota on a specific printer given (username, printername).""" 84 pass 85 86 def resetUserPQuota(self, username, printername) : 87 """Resets the page counter to zero. Life time page counter is kept unchanged.""" 81 88 pass 82 89 -
pykota/trunk/pykota/storages/sql.py
r765 r768 15 15 # 16 16 # $Log$ 17 # Revision 1.16 2003/02/08 22:39:46 jalet 18 # --reset command line option added 19 # 17 20 # Revision 1.15 2003/02/08 22:12:09 jalet 18 21 # Life time counter for users and groups added. … … 135 138 136 139 def addUserPQuota(self, username, printername) : 140 """Initializes a user print quota on a printer, adds the printer and the user to the quota storage if needed.""" 137 141 (userid, printerid) = self.getUPIds(username, printername) 138 142 if printerid is None : … … 152 156 (userid, printerid) = self.getUPIds(username, printername) 153 157 if (userid is not None) and (printerid is not None) : 154 result = self.doQuery("SELECT pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid)))158 result = self.doQuery("SELECT lifepagecounter, pagecounter, softlimit, hardlimit, datelimit FROM userpquota WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid))) 155 159 try : 156 160 return self.doParseResult(result)[0] … … 163 167 if (userid is not None) and (printerid is not None) : 164 168 self.doQuery("UPDATE userpquota SET softlimit=%s, hardlimit=%s, datelimit=NULL WHERE userid=%s AND printerid=%s;" % (self.doQuote(softlimit), self.doQuote(hardlimit), self.doQuote(userid), self.doQuote(printerid))) 169 170 def resetUserPQuota(self, username, printername) : 171 """Resets the page counter to zero. Life time page counter is kept unchanged.""" 172 (userid, printerid) = self.getUPIds(username, printername) 173 if (userid is not None) and (printerid is not None) : 174 self.doQuery("UPDATE userpquota SET pagecounter=0 WHERE userid=%s AND printerid=%s;" % (self.doQuote(userid), self.doQuote(printerid))) 165 175 166 176 def setDateLimit(self, username, printername, datelimit) :