Changeset 2512
- Timestamp:
- 09/27/05 20:34:31 (19 years ago)
- Location:
- pykota/trunk
- Files:
-
- 14 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/autopykota
r2447 r2512 28 28 import os 29 29 30 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_30 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 31 31 32 32 __doc__ = N_("""autopykota v%(__version__)s (c) %(__years__)s %(__author__)s … … 115 115 automat.display_version_and_quit() 116 116 elif args : 117 raise PyKota ToolError, "autopykota doesn't accept non option arguments !"117 raise PyKotaCommandLineError, "autopykota doesn't accept non option arguments !" 118 118 else : 119 119 retcode = automat.main(args, options) 120 120 except KeyboardInterrupt : 121 121 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 122 except PyKotaCommandLineError, msg : 123 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 122 124 except SystemExit : 123 125 pass -
pykota/trunk/bin/dumpykota
r2344 r2512 29 29 30 30 from pykota import version 31 from pykota.tool import PyKotaToolError, crashed, N_31 from pykota.tool import PyKotaToolError, PyKotaCommandLineError, crashed, N_ 32 32 from pykota.dumper import DumPyKota 33 33 … … 154 154 dumper.display_version_and_quit() 155 155 elif options["data"] is None : 156 raise PyKota ToolError, _("The -d | --data command line option is mandatory, see help.")156 raise PyKotaCommandLineError, _("The -d | --data command line option is mandatory, see help.") 157 157 else : 158 158 retcode = dumper.main(args, options) 159 159 except KeyboardInterrupt : 160 160 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 161 except PyKotaCommandLineError, msg : 162 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 161 163 except SystemExit : 162 164 pass -
pykota/trunk/bin/edpykota
r2472 r2512 29 29 import pwd 30 30 import grp 31 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_31 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 32 32 from pykota.config import PyKotaConfigError 33 33 from pykota.storage import PyKotaStorageError … … 246 246 """Edit user or group quotas.""" 247 247 if not self.config.isAdmin : 248 raise PyKota ToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))248 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 249 249 250 250 suffix = (options["groups"] and "Group") or "User" … … 261 261 if limitby not in ('quota', 'balance', 'noquota', \ 262 262 'noprint', 'nochange') : 263 raise PyKota ToolError, _("Invalid limitby value %s") % options["limitby"]263 raise PyKotaCommandLineError, _("Invalid limitby value %s") % options["limitby"] 264 264 if limitby in ('noquota', 'nochange') : 265 265 options["noquota"] = 1 266 266 if (limitby in ('nochange', 'noprint')) and options["groups"] : 267 raise PyKota ToolError, _("Invalid limitby value %s") % options["limitby"]267 raise PyKotaCommandLineError, _("Invalid limitby value %s") % options["limitby"] 268 268 269 269 used = options["used"] … … 273 273 int(used) 274 274 except ValueError : 275 raise PyKota ToolError, _("Invalid used value %s.") % used275 raise PyKotaCommandLineError, _("Invalid used value %s.") % used 276 276 277 277 increase = options["increase"] … … 280 280 increase = int(increase.strip()) 281 281 except ValueError : 282 raise PyKota ToolError, _("Invalid increase value %s.") % increase282 raise PyKotaCommandLineError, _("Invalid increase value %s.") % increase 283 283 284 284 if not options["noquota"] : … … 289 289 raise ValueError 290 290 except ValueError : 291 raise PyKota ToolError, _("Invalid softlimit value %s.") % options["softlimit"]291 raise PyKotaCommandLineError, _("Invalid softlimit value %s.") % options["softlimit"] 292 292 if options["hardlimit"] : 293 293 try : … … 296 296 raise ValueError 297 297 except ValueError : 298 raise PyKota ToolError, _("Invalid hardlimit value %s.") % options["hardlimit"]298 raise PyKotaCommandLineError, _("Invalid hardlimit value %s.") % options["hardlimit"] 299 299 if (softlimit is not None) and (hardlimit is not None) and (hardlimit < softlimit) : 300 300 # error, exchange them … … 307 307 overcharge = float(overcharge.strip()) 308 308 except (ValueError, AttributeError) : 309 raise PyKota ToolError, _("Invalid overcharge value %s") % options["overcharge"]309 raise PyKotaCommandLineError, _("Invalid overcharge value %s") % options["overcharge"] 310 310 311 311 balance = options["balance"] … … 315 315 balancevalue = float(balance) 316 316 except ValueError : 317 raise PyKota ToolError, _("Invalid balance value %s") % options["balance"]317 raise PyKotaCommandLineError, _("Invalid balance value %s") % options["balance"] 318 318 319 319 if options["charge"] : … … 321 321 charges = [float(part) for part in options["charge"].split(',', 1)] 322 322 except ValueError : 323 raise PyKota ToolError, _("Invalid charge amount value %s") % options["charge"]323 raise PyKotaCommandLineError, _("Invalid charge amount value %s") % options["charge"] 324 324 else : 325 325 if len(charges) > 2 : … … 346 346 raise PyKotaToolError, _("Impossible to add printer %s") % pname 347 347 else : 348 raise PyKota ToolError, _("Invalid printer name %s") % pname348 raise PyKotaCommandLineError, _("Invalid printer name %s") % pname 349 349 else : 350 raise PyKota ToolError, _("There's no printer matching %s") % pname350 raise PyKotaCommandLineError, _("There's no printer matching %s") % pname 351 351 if not names : 352 352 if options["delete"] : 353 raise PyKota ToolError, _("You have to pass user or group names on the command line")353 raise PyKotaCommandLineError, _("You have to pass user or group names on the command line") 354 354 else : 355 355 names = getattr(self.storage, "getAll%ssNames" % suffix)() # all users or groups … … 362 362 protoentry = getattr(self.storage, "get%s" % suffix)(options["prototype"]) 363 363 if not protoentry.Exists : 364 raise PyKota ToolError, _("Prototype object %s not found in Quota Storage.") % protoentry.Name364 raise PyKotaCommandLineError, _("Prototype object %s not found in Quota Storage.") % protoentry.Name 365 365 else : 366 366 limitby = protoentry.LimitBy … … 598 598 editor.display_version_and_quit() 599 599 elif options["users"] and options["groups"] : 600 raise PyKota ToolError, _("incompatible options, see help.")600 raise PyKotaCommandLineError, _("incompatible options, see help.") 601 601 elif (options["add"] or options["prototype"]) and options["delete"] : 602 raise PyKota ToolError, _("incompatible options, see help.")602 raise PyKotaCommandLineError, _("incompatible options, see help.") 603 603 elif (options["reset"] or options["hardreset"] or options["limitby"] or options["used"] or options["balance"] or options["overcharge"] or options["softlimit"] or options["hardlimit"]) and options["prototype"] : 604 raise PyKota ToolError, _("incompatible options, see help.")604 raise PyKotaCommandLineError, _("incompatible options, see help.") 605 605 elif options["noquota"] and (options["prototype"] or options["hardlimit"] or options["softlimit"]) : 606 raise PyKota ToolError, _("incompatible options, see help.")606 raise PyKotaCommandLineError, _("incompatible options, see help.") 607 607 elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["overcharge"]) : 608 raise PyKota ToolError, _("incompatible options, see help.")608 raise PyKotaCommandLineError, _("incompatible options, see help.") 609 609 elif options["comment"] and not options["balance"] : 610 raise PyKota ToolError, _("incompatible options, see help.")610 raise PyKotaCommandLineError, _("incompatible options, see help.") 611 611 else : 612 612 retcode = editor.main(args, options) 613 613 except KeyboardInterrupt : 614 614 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 615 except PyKotaCommandLineError, msg : 616 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 615 617 except SystemExit : 616 618 pass -
pykota/trunk/bin/pkbanner
r2344 r2512 47 47 hasPIL = 1 48 48 49 from pykota.tool import Tool, PyKotaToolError, crashed, N_49 from pykota.tool import Tool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 50 50 51 51 __doc__ = N_("""pkbanner v%(__version__)s (c) %(__years__)s %(__author__)s … … 312 312 except KeyboardInterrupt : 313 313 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 314 except PyKotaCommandLineError, msg : 315 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 314 316 except SystemExit : 315 317 pass -
pykota/trunk/bin/pkbcodes
r2344 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_("""pkbcodes v%(__version__)s (c) %(__years__)s %(__author__)s … … 87 87 """Manage billing codes.""" 88 88 if (not self.config.isAdmin) and (not options["list"]) : 89 raise PyKota ToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))89 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 90 90 91 91 if (options["list"] or options["reset"]) and not names : … … 111 111 billingcodes = self.storage.getMatchingBillingCodes(",".join(names)) 112 112 if not billingcodes : 113 raise PyKota ToolError, _("There's no billingcode matching %s") % " ".join(names)113 raise PyKotaCommandLineError, _("There's no billingcode matching %s") % " ".join(names) 114 114 115 115 for billingcode in billingcodes : … … 160 160 or (options["skipexisting"] and not options["add"]) \ 161 161 or (options["list"] and (options["add"] or options["delete"] or options["reset"] or options["description"])) : 162 raise PyKota ToolError, _("incompatible options, see help.")162 raise PyKotaCommandLineError, _("incompatible options, see help.") 163 163 elif (not args) and (options["add"] or options["delete"]) : 164 raise PyKota ToolError, _("You have to pass billing codes on the command line")164 raise PyKotaCommandLineError, _("You have to pass billing codes on the command line") 165 165 else : 166 166 retcode = manager.main(args, options) 167 167 except KeyboardInterrupt : 168 168 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 169 except PyKotaCommandLineError, msg : 170 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 169 171 except SystemExit : 170 172 pass -
pykota/trunk/bin/pkmail
r2352 r2512 31 31 import email 32 32 33 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_33 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 34 34 35 35 __doc__ = N_("""pkmail v%(__version__)s (c) %(__years__)s %(__author__)s … … 87 87 (command, arguments) = (cmdargs[0].capitalize(), cmdargs[1:]) 88 88 except IndexError : 89 raise PyKota ToolError, "No command found !"89 raise PyKotaCommandLineError, "No command found !" 90 90 91 91 badchars = """/<>&"'#!%*$,;\\""" … … 159 159 except KeyboardInterrupt : 160 160 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 161 except PyKotaCommandLineError, msg : 162 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 161 163 except SystemExit : 162 164 pass -
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 -
pykota/trunk/bin/pkturnkey
r2509 r2512 32 32 import signal 33 33 34 from pykota.tool import Tool, PyKotaToolError, crashed, N_34 from pykota.tool import Tool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 35 35 36 36 __doc__ = N_("""pkturnkey v%(__version__)s (c) %(__years__)s %(__author__)s … … 342 342 """Intializes PyKota's database.""" 343 343 if not self.config.isAdmin : 344 raise PyKota ToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0],\344 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0],\ 345 345 _("You're not allowed to use this command.")) 346 346 … … 366 366 uidmin = pwd.getpwnam(options["uidmin"])[2] 367 367 except KeyError, msg : 368 raise PyKota ToolError, _("Unknown username %s : %s") \368 raise PyKotaCommandLineError, _("Unknown username %s : %s") \ 369 369 % (options["uidmin"], msg) 370 370 … … 378 378 uidmax = pwd.getpwnam(options["uidmax"])[2] 379 379 except KeyError, msg : 380 raise PyKota ToolError, _("Unknown username %s : %s") \380 raise PyKotaCommandLineError, _("Unknown username %s : %s") \ 381 381 % (options["uidmax"], msg) 382 382 … … 398 398 gidmin = grp.getgrnam(options["gidmin"])[2] 399 399 except KeyError, msg : 400 raise PyKota ToolError, _("Unknown groupname %s : %s") \400 raise PyKotaCommandLineError, _("Unknown groupname %s : %s") \ 401 401 % (options["gidmin"], msg) 402 402 … … 410 410 gidmax = grp.getgrnam(options["gidmax"])[2] 411 411 except KeyError, msg : 412 raise PyKota ToolError, _("Unknown groupname %s : %s") \412 raise PyKotaCommandLineError, _("Unknown groupname %s : %s") \ 413 413 % (options["gidmax"], msg) 414 414 … … 492 492 except KeyboardInterrupt : 493 493 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 494 except PyKotaCommandLineError, msg : 495 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 494 496 except SystemExit : 495 497 pass -
pykota/trunk/bin/pykosd
r2344 r2512 36 36 sys.exit(-1) 37 37 38 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_38 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 39 39 40 40 __doc__ = N_("""pykosd v%(__version__)s (c) %(__years__)s %(__author__)s … … 83 83 try : 84 84 duration = int(options["duration"]) 85 except : 86 raise PyKotaToolError, _("Invalid duration option %s") % str(options["duration"]) 85 if duration <= 0 : 86 raise ValueError 87 except : 88 raise PyKotaCommandLineError, _("Invalid duration option %s") % str(options["duration"]) 87 89 88 90 try : 89 91 loop = int(options["loop"]) 90 except : 91 raise PyKotaToolError, _("Invalid loop option %s") % str(options["loop"]) 92 if loop < 0 : 93 raise ValueError 94 except : 95 raise PyKotaCommandLineError, _("Invalid loop option %s") % str(options["loop"]) 92 96 93 97 try : 94 98 sleep = float(options["sleep"]) 95 except : 96 raise PyKotaToolError, _("Invalid sleep option %s") % str(options["sleep"]) 99 if sleep <= 0 : 100 raise ValueError 101 except : 102 raise PyKotaCommandLineError, _("Invalid sleep option %s") % str(options["sleep"]) 97 103 98 104 color = options["color"] … … 100 106 color = "#%s" % color 101 107 if len(color) != 7 : 102 raise PyKota ToolError, _("Invalid color option %s") % str(color)108 raise PyKotaCommandLineError, _("Invalid color option %s") % str(color) 103 109 savecolor = color 104 110 … … 108 114 user = cmd.storage.getUserFromBackend(uname) # don't use cache 109 115 if not user.Exists : 110 raise PyKota ToolError, _("User %s doesn't exist in PyKota's database") % uname116 raise PyKotaCommandLineError, _("User %s doesn't exist in PyKota's database") % uname 111 117 if user.LimitBy == "quota" : 112 118 printers = cmd.storage.getMatchingPrinters("*") … … 177 183 except KeyboardInterrupt : 178 184 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 185 except PyKotaCommandLineError, msg : 186 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 179 187 except SystemExit : 180 188 pass -
pykota/trunk/bin/pykotme
r2352 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 try : … … 96 96 printers = self.storage.getMatchingPrinters(options["printer"]) 97 97 if not printers : 98 raise PyKota ToolError, _("There's no printer matching %s") % options["printer"]98 raise PyKotaCommandLineError, _("There's no printer matching %s") % options["printer"] 99 99 100 100 username = pwd.getpwuid(os.getuid())[0] … … 140 140 except KeyboardInterrupt : 141 141 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 142 except PyKotaCommandLineError, msg : 143 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 142 144 except SystemExit : 143 145 pass -
pykota/trunk/bin/repykota
r2452 r2512 31 31 from mx import DateTime 32 32 33 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_ 34 from pykota.config import PyKotaConfigError 35 from pykota.storage import PyKotaStorageError 36 from pykota.reporter import PyKotaReporterError 33 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 37 34 from pykota import reporter 38 35 … … 110 107 # reports only the current user 111 108 if options["ingroups"] : 112 raise PyKota ToolError, _("Option --ingroups is reserved to PyKota Administrators.")109 raise PyKotaCommandLineError, _("Option --ingroups is reserved to PyKota Administrators.") 113 110 114 111 username = pwd.getpwuid(os.geteuid())[0] … … 124 121 printers = self.storage.getMatchingPrinters(options["printer"]) 125 122 if not printers : 126 raise PyKota ToolError, _("There's no printer matching %s") % options["printer"]123 raise PyKotaCommandLineError, _("There's no printer matching %s") % options["printer"] 127 124 128 125 self.reportingtool = reporter.openReporter(self, "text", printers, ugnames, (options["groups"] and 1) or 0) … … 157 154 elif options["version"] : 158 155 reportTool.display_version_and_quit() 159 elif options["users"] and options["groups"] :160 raise PyKota ToolError, _("incompatible options, see help.")156 elif (options["users"] or options["ingroups"]) and options["groups"] : 157 raise PyKotaCommandLineError, _("incompatible options, see help.") 161 158 else : 162 159 retcode = reportTool.main(args, options) 163 160 except KeyboardInterrupt : 164 161 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 162 except PyKotaCommandLineError, msg : 163 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 165 164 except SystemExit : 166 165 pass -
pykota/trunk/bin/warnpykota
r2344 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 from pykota.config import PyKotaConfigError 33 33 from pykota.storage import PyKotaStorageError … … 108 108 printers = self.storage.getMatchingPrinters(options["printer"]) 109 109 if not printers : 110 raise PyKota ToolError, _("There's no printer matching %s") % options["printer"]110 raise PyKotaCommandLineError, _("There's no printer matching %s") % options["printer"] 111 111 alreadydone = {} 112 112 for printer in printers : … … 155 155 sender.display_version_and_quit() 156 156 elif options["users"] and options["groups"] : 157 raise PyKota ToolError, _("incompatible options, see help.")157 raise PyKotaCommandLineError, _("incompatible options, see help.") 158 158 else : 159 159 retcode = sender.main(args, options) 160 160 except KeyboardInterrupt : 161 161 sys.stderr.write("\nInterrupted with Ctrl+C !\n") 162 except PyKotaCommandLineError, msg : 163 sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 162 164 except SystemExit : 163 165 pass -
pykota/trunk/pykota/dumper.py
r2342 r2512 39 39 40 40 from pykota import version 41 from pykota.tool import PyKotaTool, PyKotaToolError, N_41 from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, N_ 42 42 43 43 class DumPyKota(PyKotaTool) : … … 72 72 """Print Quota Data Dumper.""" 73 73 if restricted and not self.config.isAdmin : 74 raise PyKota ToolError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command."))74 raise PyKotaCommandLineError, "%s : %s" % (pwd.getpwuid(os.geteuid())[0], _("You're not allowed to use this command.")) 75 75 76 76 extractonly = {} … … 82 82 raise ValueError 83 83 except ValueError : 84 raise PyKota ToolError, _("Invalid filter value [%s], see help.") % filterexp84 raise PyKotaCommandLineError, _("Invalid filter value [%s], see help.") % filterexp 85 85 else : 86 86 extractonly.update({ filterkey : filtervalue }) … … 88 88 datatype = options["data"] 89 89 if datatype not in self.validdatatypes.keys() : 90 raise PyKota ToolError, _("Invalid modifier [%s] for --data command line option, see help.") % datatype90 raise PyKotaCommandLineError, _("Invalid modifier [%s] for --data command line option, see help.") % datatype 91 91 92 92 format = options["format"] 93 93 if (format not in self.validformats.keys()) \ 94 94 or ((format == "cups") and ((datatype != "history") or options["sum"])) : 95 raise PyKota ToolError, _("Invalid modifier [%s] for --format command line option, see help.") % format95 raise PyKotaCommandLineError, _("Invalid modifier [%s] for --format command line option, see help.") % format 96 96 97 97 if (format == "xml") and not hasJAXML : … … 99 99 100 100 if options["sum"] and datatype not in ("payments", "history") : 101 raise PyKota ToolError, _("Invalid data type [%s] for --sum command line option, see help.") % datatype101 raise PyKotaCommandLineError, _("Invalid data type [%s] for --sum command line option, see help.") % datatype 102 102 103 103 entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly) -
pykota/trunk/pykota/tool.py
r2511 r2512 53 53 54 54 class PyKotaToolError(Exception): 55 """An exception for PyKota configrelated stuff."""55 """An exception for PyKota related stuff.""" 56 56 def __init__(self, message = ""): 57 57 self.message = message … … 60 60 return self.message 61 61 __str__ = __repr__ 62 63 class PyKotaCommandLineError(PyKotaToolError) : 64 """An exception for Pykota command line tools.""" 65 pass 62 66 63 67 def crashed(message="Bug in PyKota") :