| 155 | def modifyPQEntry(self, pqkey, pqentry, noquota, softlimit, hardlimit, increase, reset, hardreset, suffix, used) : |
| 156 | """Modifies a print quota entry.""" |
| 157 | if noquota or ((softlimit is not None) and (hardlimit is not None)) : |
| 158 | pqentry.setLimits(softlimit, hardlimit) |
| 159 | if increase : |
| 160 | newsoft = (pqentry.SoftLimit or 0) + increase |
| 161 | newhard = (pqentry.HardLimit or 0) + increase |
| 162 | if (newsoft >= 0) and (newhard >= 0) : |
| 163 | pqentry.setLimits(newsoft, newhard) |
| 164 | else : |
| 165 | self.printInfo(_("You can't set negative limits for %s") % pqkey, "error") |
| 166 | if reset : |
| 167 | pqentry.reset() |
| 168 | if hardreset : |
| 169 | pqentry.hardreset() |
| 170 | if suffix == "User" : |
| 171 | if used : |
| 172 | pqentry.setUsage(used) |
| 173 | |
| 194 | elif options["list"] : |
| 195 | for printer in printers : |
| 196 | for entry in entries : |
| 197 | pqentry = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer) |
| 198 | if pqentry.Exists : |
| 199 | print "%s@%s" % (entry.Name, printer.Name) |
| 200 | print " %s" % (_("Page counter : %s") % pqentry.PageCounter) |
| 201 | print " %s" % (_("Lifetime page counter : %s") % pqentry.LifePageCounter) |
| 202 | print " %s" % (_("Soft limit : %s") % pqentry.SoftLimit) |
| 203 | print " %s" % (_("Hard limit : %s") % pqentry.HardLimit) |
| 204 | print " %s" % (_("Date limit : %s") % pqentry.DateLimit) |
| 205 | print " %s (Not supported yet)" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited"))) |
| 206 | if hasattr(pqentry, "WarnCount") : |
| 207 | print " %s" % (_("Warning banners printed : %s") % pqentry.WarnCount) |
| 208 | print |
241 | | if noquota or ((softlimit is not None) and (hardlimit is not None)) : |
242 | | pqentry.setLimits(softlimit, hardlimit) |
243 | | |
244 | | if increase : |
245 | | newsoft = (pqentry.SoftLimit or 0) + increase |
246 | | newhard = (pqentry.HardLimit or 0) + increase |
247 | | if (newsoft >= 0) and (newhard >= 0) : |
248 | | pqentry.setLimits(newsoft, newhard) |
249 | | else : |
250 | | self.printInfo(_("You can't set negative limits."), "error") |
251 | | |
252 | | if options["reset"] : |
253 | | pqentry.reset() |
254 | | |
255 | | if options["hardreset"] : |
256 | | pqentry.hardreset() |
257 | | |
258 | | if not options["groups"] : |
259 | | if used : |
260 | | pqentry.setUsage(used) |
261 | | |
| 277 | self.modifyPQEntry(pqkey, pqentry, noquota, \ |
| 278 | softlimit, hardlimit, \ |
| 279 | increase, reset, \ |
| 280 | hardreset, suffix, used) |
272 | | self.display("\r100.00%%\r \r%s" % _("Done.")) |
273 | | else : |
274 | | for printer in printers : |
275 | | for entry in entries : |
276 | | pqentries.append(getattr(self.storage, "get%sPQuota" % suffix)(entry, printer)) |
277 | | if not pqentries : |
278 | | raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names)) |
279 | | |
280 | | if options["list"] : |
281 | | for pqentry in pqentries : |
282 | | if pqentry.Exists : |
283 | | print "%s@%s" % (getattr(pqentry, suffix).Name, pqentry.Printer.Name) |
284 | | print " %s" % (_("Page counter : %s") % pqentry.PageCounter) |
285 | | print " %s" % (_("Lifetime page counter : %s") % pqentry.LifePageCounter) |
286 | | print " %s" % (_("Soft limit : %s") % pqentry.SoftLimit) |
287 | | print " %s" % (_("Hard limit : %s") % pqentry.HardLimit) |
288 | | print " %s" % (_("Date limit : %s") % pqentry.DateLimit) |
289 | | print " %s (Not supported yet)" % (_("Maximum job size : %s") % ((pqentry.MaxJobSize and (_("%s pages") % pqentry.MaxJobSize)) or _("Unlimited"))) |
290 | | if hasattr(pqentry, "WarnCount") : |
291 | | print " %s" % (_("Warning banners printed : %s") % pqentry.WarnCount) |
292 | | print |
293 | | else : |
294 | | self.display("\n") |
295 | | nbtotal = len(pqentries) |
| 295 | else : |
| 296 | nbtotal = len(entries) * len(printers) |
299 | | for pqentry in pqentries : |
300 | | ename = getattr(pqentry, suffix).Name |
301 | | pname = pqentry.Printer.Name |
302 | | if pqentry.Exists : |
303 | | if noquota or ((softlimit is not None) and (hardlimit is not None)) : |
304 | | pqentry.setLimits(softlimit, hardlimit) |
305 | | |
306 | | if increase : |
307 | | newsoft = (pqentry.SoftLimit or 0) + increase |
308 | | newhard = (pqentry.HardLimit or 0) + increase |
309 | | if (newsoft >= 0) and (newhard >= 0) : |
310 | | pqentry.setLimits(newsoft, newhard) |
311 | | else : |
312 | | self.printInfo(_("You can't set negative limits for %s@%s") % (ename, pname), "error") |
313 | | |
314 | | if options["reset"] : |
315 | | pqentry.reset() |
316 | | |
317 | | if options["hardreset"] : |
318 | | pqentry.hardreset() |
319 | | |
320 | | if not options["groups"] : |
321 | | if used : |
322 | | pqentry.setUsage(used) |
323 | | |
324 | | pqentry.save() |
325 | | i += 1 |
326 | | percent = 100.0 * float(i) / float(nbtotal) |
327 | | self.display("\r%.02f%%" % percent) |
328 | | self.display("\r100.00%%\r \r%s\n" % _("Done.")) |
| 300 | for printer in printers : |
| 301 | for entry in entries : |
| 302 | pqkey = "%s@%s" % (entry.Name, printer.Name) |
| 303 | pqentry = getattr(self.storage, "get%sPQuota" % suffix)(entry, printer) |
| 304 | if pqentry.Exists : |
| 305 | self.modifyPQEntry(pqkey, pqentry, noquota, \ |
| 306 | softlimit, hardlimit, \ |
| 307 | increase, reset, \ |
| 308 | hardreset, suffix, used) |
| 309 | pqentry.save() |
| 310 | i += 1 |
| 311 | percent = 100.0 * float(i) / float(nbtotal) |
| 312 | self.display("\r%.02f%%" % percent) |
| 313 | self.display("\r100.00%%\r \r%s\n" % _("Done.")) |