Changeset 900 for pykota/trunk/bin/edpykota
- Timestamp:
- 04/10/03 23:47:20 (21 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/edpykota
r895 r900 23 23 # 24 24 # $Log$ 25 # Revision 1.33 2003/04/10 21:47:20 jalet 26 # Job history added. Upgrade script neutralized for now ! 27 # 25 28 # Revision 1.32 2003/04/08 21:31:39 jalet 26 29 # (anything or 0) = anything !!! Go back to school Jerome ! … … 232 235 def main(self, names, options) : 233 236 """Edit user or group quotas.""" 234 printer names = self.storage.getMatchingPrinters(options["printer"])235 if not printer names :237 printers = self.storage.getMatchingPrinters(options["printer"]) 238 if not printers : 236 239 pname = options["printer"] 237 240 if options["add"] and pname : 238 241 if self.isValidName(pname) : 239 self.storage.addPrinter(pname)240 printer names = [ (pname, 0) ]242 printerid = self.storage.addPrinter(pname) 243 printers = [ (printerid, pname) ] 241 244 else : 242 245 raise PyKotaToolError, _("Invalid printer name %s") % pname … … 263 266 else : 264 267 names = [ "*" ] # all users 265 for (printer , printerpagecounter) in printernames :268 for (printerid, printer) in printers : 266 269 if options["prototype"] : 267 270 if options["groups"] : 268 prototype = self.storage.getGroupPQuota( options["prototype"], printer)271 prototype = self.storage.getGroupPQuota(self.storage.getGroupId(options["prototype"]), printerid) 269 272 else : 270 273 # default is user quota edition 271 prototype = self.storage.getUserPQuota( options["prototype"], printer)274 prototype = self.storage.getUserPQuota(self.storage.getUserId(options["prototype"]), printerid) 272 275 if prototype is None : 273 276 self.logger.log_message(_("Prototype %s not found in Quota Storage for printer %s.") % (options["prototype"], printer)) … … 283 286 if softlimit is not None : 284 287 self.logger.log_message(_("Undefined soft limit set to hard limit (%s) on printer %s.") % (str(softlimit), printer)) 285 if (not options["reset"] and not options["noquota"] ) and ((hardlimit is None) or (softlimit is None)) :288 if (not options["reset"] and not options["noquota"] and not options["prototype"]) and ((hardlimit is None) or (softlimit is None)) : 286 289 raise PyKotaToolError, _("Both hard and soft limits must be set ! Aborting.") 287 290 if options["add"] : 288 all names = names291 allidnames = [(None, n) for n in names] 289 292 else : 290 293 if options["groups"] : 291 all names = self.storage.getPrinterGroups(printer)294 allidnames = self.storage.getPrinterGroups(printerid) 292 295 else : 293 all names = self.storage.getPrinterUsers(printer)294 for name in [n for n in allnames if self.matchString(n, names)]:296 allidnames = self.storage.getPrinterUsers(printerid) 297 for (ident, name) in [(i, n) for (i, n) in allidnames if self.matchString(n, names)]: 295 298 if options["groups"] : 296 quota = self.storage.getGroupPQuota( name, printer)299 quota = self.storage.getGroupPQuota(ident, printerid) 297 300 else : 298 quota = self.storage.getUserPQuota( name, printer)301 quota = self.storage.getUserPQuota(ident, printerid) 299 302 if quota is None : 300 303 # not found … … 306 309 if options["groups"] : 307 310 if self.isValidName(name) : 308 self.storage.addGroupPQuota(name, printer)309 quota = self.storage.getGroupPQuota( name, printer)311 (ident, printerid) = self.storage.addGroupPQuota(name, printerid) 312 quota = self.storage.getGroupPQuota(ident, printerid) 310 313 else : 311 314 self.logger.log_message(_("Invalid group name %s") % name) 312 315 else : 313 316 if self.isValidName(name) : 314 self.storage.addUserPQuota(name, printer)315 quota = self.storage.getUserPQuota( name, printer)317 (ident, printerid) = self.storage.addUserPQuota(name, printerid) 318 quota = self.storage.getUserPQuota(ident, printerid) 316 319 else : 317 320 self.logger.log_message(_("Invalid user name %s") % name) … … 320 323 else : 321 324 if options["groups"] : 322 if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) :323 self.storage.setGroupPQuota( name, printer, softlimit, hardlimit)325 if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 326 self.storage.setGroupPQuota(ident, printerid, softlimit, hardlimit) 324 327 if options["reset"] : 325 self.storage.resetGroupPQuota(name, printer) 328 self.storage.resetGroupPQuota(ident, printerid) 329 self.warnGroupPQuota(name, printer) 326 330 else : 327 if options["noquota"] or ((softlimit is not None) and (hardlimit is not None)) :328 self.storage.setUserPQuota( name, printer, softlimit, hardlimit)331 if options["noquota"] or options["prototype"] or ((softlimit is not None) and (hardlimit is not None)) : 332 self.storage.setUserPQuota(ident, printerid, softlimit, hardlimit) 329 333 if options["reset"] : 330 self.storage.resetUserPQuota(name, printer) 334 self.storage.resetUserPQuota(ident, printerid) 335 self.warnUserPQuota(name, printer) 331 336 332 337 if __name__ == "__main__" :