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/pykota/dumper.py

    r2342 r2512  
    3939 
    4040from pykota import version 
    41 from pykota.tool import PyKotaTool, PyKotaToolError, N_ 
     41from pykota.tool import PyKotaTool, PyKotaToolError, PyKotaCommandLineError, N_ 
    4242 
    4343class DumPyKota(PyKotaTool) :         
     
    7272        """Print Quota Data Dumper.""" 
    7373        if restricted and not self.config.isAdmin : 
    74             raise PyKotaToolError, "%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.")) 
    7575             
    7676        extractonly = {} 
     
    8282                        raise ValueError                 
    8383                except ValueError :     
    84                     raise PyKotaToolError, _("Invalid filter value [%s], see help.") % filterexp 
     84                    raise PyKotaCommandLineError, _("Invalid filter value [%s], see help.") % filterexp 
    8585                else :     
    8686                    extractonly.update({ filterkey : filtervalue }) 
     
    8888        datatype = options["data"] 
    8989        if datatype not in self.validdatatypes.keys() : 
    90             raise PyKotaToolError, _("Invalid modifier [%s] for --data command line option, see help.") % datatype 
     90            raise PyKotaCommandLineError, _("Invalid modifier [%s] for --data command line option, see help.") % datatype 
    9191                     
    9292        format = options["format"] 
    9393        if (format not in self.validformats.keys()) \ 
    9494              or ((format == "cups") and ((datatype != "history") or options["sum"])) : 
    95             raise PyKotaToolError, _("Invalid modifier [%s] for --format command line option, see help.") % format 
     95            raise PyKotaCommandLineError, _("Invalid modifier [%s] for --format command line option, see help.") % format 
    9696             
    9797        if (format == "xml") and not hasJAXML : 
     
    9999             
    100100        if options["sum"] and datatype not in ("payments", "history") :  
    101             raise PyKotaToolError, _("Invalid data type [%s] for --sum command line option, see help.") % datatype 
     101            raise PyKotaCommandLineError, _("Invalid data type [%s] for --sum command line option, see help.") % datatype 
    102102             
    103103        entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly)