Changeset 2512 for pykota/trunk/bin/pkprinters
- Timestamp:
- 09/27/05 20:34:31 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pkprinters
r2465 r2512 29 29 import pwd 30 30 31 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_31 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 32 32 33 33 __doc__ = N_("""pkprinters v%(__version__)s (c) %(__years__)s %(__author__)s … … 127 127 """Manage printers.""" 128 128 if (not self.config.isAdmin) and (not options["list"]) : 129 raise PyKota ToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))129 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 130 130 131 131 if options["list"] and not names : … … 135 135 printersgroups = self.storage.getMatchingPrinters(options["groups"]) 136 136 if not printersgroups : 137 raise PyKota ToolError, _("There's no printer matching %s") % " ".join(options["groups"].split(','))137 raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(options["groups"].split(',')) 138 138 139 139 if options["charge"] : … … 141 141 charges = [float(part) for part in options["charge"].split(',', 1)] 142 142 except ValueError : 143 raise PyKota ToolError, _("Invalid charge amount value %s") % options["charge"]143 raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"] 144 144 else : 145 145 if len(charges) > 2 : … … 155 155 raise ValueError 156 156 except ValueError : 157 raise PyKota ToolError, _("Invalid maximum job size value %s") % options["maxjobsize"]157 raise PyKotaCommandLineError, _("Invalid maximum job size value %s") % options["maxjobsize"] 158 158 else : 159 159 maxjobsize = None … … 178 178 printers.append(printer) 179 179 else : 180 raise PyKota ToolError, _("Invalid printer name %s") % pname180 raise PyKotaCommandLineError, _("Invalid printer name %s") % pname 181 181 else : 182 182 printers = self.storage.getMatchingPrinters(",".join(names)) 183 183 if not printers : 184 raise PyKota ToolError, _("There's no printer matching %s") % " ".join(names)184 raise PyKotaCommandLineError, _("There's no printer matching %s") % " ".join(names) 185 185 186 186 for printer in printers : … … 255 255 or (options["list"] and (options["add"] or options["delete"] or options["groups"] or options["charge"] or options["remove"] or options["description"])) \ 256 256 or (options["passthrough"] and options["nopassthrough"]) : 257 raise PyKota ToolError, _("incompatible options, see help.")257 raise PyKotaCommandLineError, _("incompatible options, see help.") 258 258 elif options["remove"] and not options["groups"] : 259 raise PyKota ToolError, _("You have to pass printer groups names on the command line")259 raise PyKotaCommandLineError, _("You have to pass printer groups names on the command line") 260 260 elif (not args) and (not options["list"]) : 261 raise PyKota ToolError, _("You have to pass printer names on the command line")261 raise PyKotaCommandLineError, _("You have to pass printer names on the command line") 262 262 else : 263 263 retcode = manager.main(args, options) 264 264 except KeyboardInterrupt : 265 265 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 266 except PyKotaCommandLineError, msg : 267 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 266 268 except SystemExit : 267 269 pass