Show
Ignore:
Timestamp:
09/27/05 20:34:31 (19 years ago)
Author:
jerome
Message:

Ensure that human made errors (like incorrect command line options)
don't produce a traceback anymore. No need to frighten users with
such complete tracebacks and email reporting each time they mistype
some command.
Makes pykosd check more carefully the values of its command line options.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/repykota

    r2452 r2512  
    3131from mx import DateTime 
    3232 
    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 
     33from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, crashed, N_ 
    3734from pykota import reporter 
    3835 
     
    110107            # reports only the current user 
    111108            if options["ingroups"] : 
    112                 raise PyKotaToolError, _("Option --ingroups is reserved to PyKota Administrators.") 
     109                raise PyKotaCommandLineError, _("Option --ingroups is reserved to PyKota Administrators.") 
    113110                 
    114111            username = pwd.getpwuid(os.geteuid())[0] 
     
    124121        printers = self.storage.getMatchingPrinters(options["printer"]) 
    125122        if not printers : 
    126             raise PyKotaToolError, _("There's no printer matching %s") % options["printer"] 
     123            raise PyKotaCommandLineError, _("There's no printer matching %s") % options["printer"] 
    127124             
    128125        self.reportingtool = reporter.openReporter(self, "text", printers, ugnames, (options["groups"] and 1) or 0)     
     
    157154        elif options["version"] : 
    158155            reportTool.display_version_and_quit() 
    159         elif options["users"] and options["groups"] :     
    160             raise PyKotaToolError, _("incompatible options, see help.") 
     156        elif (options["users"] or options["ingroups"]) and options["groups"] : 
     157            raise PyKotaCommandLineError, _("incompatible options, see help.") 
    161158        else : 
    162159            retcode = reportTool.main(args, options) 
    163160    except KeyboardInterrupt :         
    164161        sys.stderr.write("\nInterrupted with Ctrl+C !\n") 
     162    except PyKotaCommandLineError, msg :     
     163        sys.stderr.write("%s : %s\n" % (sys.argv[0], msg)) 
    165164    except SystemExit :         
    166165        pass