172 | | if not options["list"] : |
173 | | self.display("%s...\n" % _("Modification")) |
174 | | |
175 | | if options["groups"] : |
176 | | printersgroups = self.storage.getMatchingPrinters(options["groups"]) |
177 | | if not printersgroups : |
178 | | raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(options["groups"].split(',')) |
179 | | |
180 | | if options["charge"] : |
181 | | try : |
182 | | charges = [float(part) for part in options["charge"].split(',', 1)] |
183 | | except ValueError : |
184 | | raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"] |
185 | | else : |
186 | | if len(charges) > 2 : |
187 | | charges = charges[:2] |
188 | | if len(charges) != 2 : |
189 | | charges = [charges[0], None] |
190 | | (perpage, perjob) = charges |
191 | | |
192 | | if options["maxjobsize"] : |
193 | | try : |
194 | | maxjobsize = int(options["maxjobsize"]) |
195 | | if maxjobsize < 0 : |
196 | | raise ValueError |
197 | | except ValueError : |
198 | | raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options["maxjobsize"] |
199 | | else : |
200 | | maxjobsize = None |
201 | | |
202 | | nbtotal = len(printers) |
203 | | for i in range(nbtotal) : |
204 | | printer = printers[i] |
205 | | if options["list"] : |
| 172 | if options["list"] : |
| 173 | for printer in printers : |
216 | | else : |
| 184 | else : |
| 185 | self.display("%s...\n" % _("Modification")) |
| 186 | |
| 187 | if options["groups"] : |
| 188 | printersgroups = self.storage.getMatchingPrinters(options["groups"]) |
| 189 | if not printersgroups : |
| 190 | raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(options["groups"].split(',')) |
| 191 | else : |
| 192 | printersgroups = [] |
| 193 | |
| 194 | if options["charge"] : |
| 195 | try : |
| 196 | charges = [float(part) for part in options["charge"].split(',', 1)] |
| 197 | except ValueError : |
| 198 | raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"] |
| 199 | else : |
| 200 | if len(charges) > 2 : |
| 201 | charges = charges[:2] |
| 202 | if len(charges) != 2 : |
| 203 | charges = [charges[0], None] |
| 204 | (perpage, perjob) = charges |
| 205 | |
| 206 | if options["maxjobsize"] : |
| 207 | try : |
| 208 | maxjobsize = int(options["maxjobsize"]) |
| 209 | if maxjobsize < 0 : |
| 210 | raise ValueError |
| 211 | except ValueError : |
| 212 | raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options["maxjobsize"] |
| 213 | else : |
| 214 | maxjobsize = None |
| 215 | |
| 216 | if options["description"] : |
| 217 | description = options["description"].strip() |
| 218 | nopassthrough = options["nopassthrough"] |
| 219 | passthrough = options["passthrough"] |
| 220 | nbtotal = len(printers) |
| 221 | for i in range(nbtotal) : |
| 222 | printer = printers[i] |
219 | | if options["description"] is not None : |
220 | | printer.setDescription(options["description"].strip()) |
221 | | if options["nopassthrough"] and printer.PassThrough : |
222 | | self.storage.setPrinterPassThroughMode(printer, 0) |
223 | | if options["passthrough"] and not printer.PassThrough : |
224 | | self.storage.setPrinterPassThroughMode(printer, 1) |
| 225 | if description is not None : # NB : "" is allowed ! |
| 226 | printer.setDescription(description) |
| 227 | if nopassthrough and printer.PassThrough : |
| 228 | printer.setPassThrough(False) |
| 229 | if passthrough and not printer.PassThrough : |
| 230 | printer.setPassThrough(True) |