173 | | raise PyKotaCommandLineError, "Not implemented yet." |
174 | | else : |
175 | | if not names : |
176 | | names = ["*"] |
177 | | (printers, entries, pqentries) = getattr(self.storage, "getPrinters%ssAndPQuotas" % suffix)(options["printer"].split(","), names) |
178 | | if not pqentries : |
179 | | raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names)) |
| 177 | self.display("%s...\n" % _("Creation")) |
| 178 | mprinters = self.storage.getMatchingPrinters(options["printer"]) |
| 179 | mentries = getattr(self.storage, "getMatching%ss" % suffix)(",".join(names)) |
| 180 | nbtotal = len(mprinters) * len(mentries) |
| 181 | i = 0 |
| 182 | for printer in mprinters : |
| 183 | pname = printer.Name |
| 184 | for entry in mentries : |
| 185 | ename = entry.Name |
| 186 | pqkey = "%s@%s" % (ename, pname) |
| 187 | if pqentries.has_key(pqkey) and pqentries[pqkey].Exists : |
| 188 | if skipexisting : |
| 189 | self.printInfo(_("%s print quota entry %s@%s already exists, skipping.") % (suffix, ename, pname)) |
| 190 | del pqentries[pqkey] |
| 191 | else : |
| 192 | self.printInfo(_("%s print quota entry %s@%s already exists, will be modified.") % (suffix, ename, pname)) |
| 193 | else : |
| 194 | newpqentry = getattr(self.storage, "add%sPQuota" % suffix)(entry, printer) |
| 195 | if not newpqentry.Exists : |
| 196 | self.printInfo(_("Impossible to create a print quota entry for %s@%s") % (ename, pname)) |
| 197 | else : |
| 198 | pqentries[pqkey] = newpqentry |
| 199 | percent = 100.0 * float(i) / float(nbtotal) |
| 200 | self.display("\r%.02f%%" % percent) |
| 201 | i += 1 |
| 202 | self.display("\r100.00%%\r \r%s\n" % _("Done.")) |
| 203 | |
| 204 | if not pqentries : |
| 205 | raise PyKotaCommandLineError, _("There's no %s print quota entry matching %s") % (suffix.lower(), " ".join(names)) |