142 | | if options["list"] and not names : |
143 | | names = ["*"] |
| 140 | if options["add"] : |
| 141 | self.display("%s...\n" % _("Creation")) |
| 142 | printers = [] |
| 143 | nbtotal = len(names) |
| 144 | for i in range(nbtotal) : |
| 145 | pname = names[i] |
| 146 | printer = self.storage.getPrinter(pname) |
| 147 | if printer.Exists : |
| 148 | if options["skipexisting"] : |
| 149 | self.printInfo(_("Printer %s already exists, skipping.") % printer.Name) |
| 150 | else : |
| 151 | self.printInfo(_("Printer %s already exists, will be modified.") % printer.Name) |
| 152 | printers.append(printer) |
| 153 | else : |
| 154 | if self.isValidName(pname) : |
| 155 | printer = self.storage.addPrinter(pname) |
| 156 | if not printer.Exists : |
| 157 | raise PyKotaToolError, _("Impossible to add printer %s") % pname |
| 158 | else : |
| 159 | printers.append(printer) |
| 160 | else : |
| 161 | raise PyKotaCommandLineError, _("Invalid printer name %s") % pname |
| 162 | percent = 100.0 * float(i) / float(nbtotal) |
| 163 | self.display("\r%.02f%%" % percent) |
| 164 | self.display("\r100.00%%\r \r%s\n" % _("Done.")) |
| 165 | else : |
| 166 | if not names : |
| 167 | names = ["*"] |
| 168 | printers = self.storage.getMatchingPrinters(",".join(names)) |
| 169 | if not printers : |
| 170 | raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names) |
| 171 | |
| 172 | if not options["list"] : |
| 173 | self.display("%s...\n" % _("Modification")) |
172 | | |
173 | | if options["add"] : |
174 | | printers = [] |
175 | | for pname in names : |
176 | | printer = self.storage.getPrinter(pname) |
177 | | if printer.Exists : |
178 | | if options["skipexisting"] : |
179 | | self.printInfo(_("Printer %s already exists, skipping.") % printer.Name) |
180 | | else : |
181 | | self.printInfo(_("Printer %s already exists, will be modified.") % printer.Name) |
182 | | printers.append(printer) |
183 | | else : |
184 | | if self.isValidName(pname) : |
185 | | printer = self.storage.addPrinter(pname) |
186 | | if not printer.Exists : |
187 | | raise PyKotaToolError, _("Impossible to add printer %s") % pname |
188 | | else : |
189 | | printers.append(printer) |
190 | | else : |
191 | | raise PyKotaCommandLineError, _("Invalid printer name %s") % pname |
192 | | else : |
193 | | printers = self.storage.getMatchingPrinters(",".join(names)) |
194 | | if not printers : |
195 | | raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names) |
196 | | |
197 | | for printer in printers : |
| 202 | nbtotal = len(printers) |
| 203 | for i in range(nbtotal) : |
| 204 | printer = printers[i] |