Changeset 2512 for pykota/trunk/bin/edpykota
- Timestamp:
- 09/27/05 20:34:31 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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