Changeset 1437 for pykota/trunk/bin
- Timestamp:
- 04/16/04 18:47:58 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkprinters
r1332 r1437 24 24 # 25 25 # $Log$ 26 # Revision 1.4 2004/04/16 16:47:57 jalet 27 # pkprinters now accept the --list command line option 28 # 26 29 # Revision 1.3 2004/02/04 13:24:41 jalet 27 30 # pkprinters can now remove printers from printers groups. … … 80 83 printer groups. 81 84 85 -l | --list List informations about the printer(s) and the 86 printers groups it is a member of. 87 82 88 -r | --remove In combination with the --groups option above, 83 89 remove printers from the specified printers groups. … … 130 136 def main(self, names, options) : 131 137 """Manage printers.""" 138 if options["list"] and not names : 139 names = ["*"] 140 132 141 if options["groups"] : 133 142 printersgroups = self.storage.getMatchingPrinters(options["groups"]) … … 167 176 if options["delete"] : 168 177 printer.delete() 178 elif options["list"] : 179 parents = ", ".join([p.Name for p in self.storage.getParentPrinters(printer)]) 180 if parents : 181 parents = "%s %s" % (_("in"), parents) 182 print "%s (%s + %s) %s" % \ 183 (printer.Name, printer.PricePerJob, \ 184 printer.PricePerPage, parents) 169 185 else : 170 186 if options["charge"] : … … 180 196 retcode = 0 181 197 try : 182 short_options = "hvac:dg: r"183 long_options = ["help", "version", "add", "charge=", "delete", "groups=", " remove"]198 short_options = "hvac:dg:lr" 199 long_options = ["help", "version", "add", "charge=", "delete", "groups=", "list", "remove"] 184 200 185 201 # Initializes the command line tool … … 196 212 options["delete"] = options["d"] or options["delete"] 197 213 options["groups"] = options["g"] or options["groups"] 214 options["list"] = options["l"] or options["list"] 198 215 options["remove"] = options["r"] or options["remove"] 199 216 … … 202 219 elif options["version"] : 203 220 manager.display_version_and_quit() 204 elif options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"]) : 221 elif (options["delete"] and (options["add"] or options["groups"] or options["charge"] or options["remove"])) \ 222 or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"])) : 205 223 raise PyKotaToolError, _("incompatible options, see help.") 206 224 elif options["remove"] and not options["groups"] : 207 225 raise PyKotaToolError, _("You have to pass printer groups names on the command line") 208 elif not args:226 elif (not args) and (not options["list"]) : 209 227 raise PyKotaToolError, _("You have to pass printer names on the command line") 210 228 else :