(self, parser = None)
return p
Initialize a OptionParser() instance that will be used to
        parse command line arguments.

        Note that it can be overridden both directions - either DBScript
        will initialize an instance and pass it to user code or user can
        initialize and then pass to DBScript.init_optparse().

        @param parser: optional OptionParser() instance,
               where DBScript should attach its own arguments.
        @return: initialized OptionParser() instance.
Initialize a OptionParser() instance that will be used to
        parse command line arguments.
Initialize a OptionParser () instance that will be used to parse command line arguments .
def init_optparse(self, parser = None):
        """Initialize a OptionParser() instance that will be used to
        parse command line arguments.

        Note that it can be overridden both directions - either DBScript
        will initialize an instance and pass it to user code or user can
        initialize and then pass to DBScript.init_optparse().

        @param parser: optional OptionParser() instance,
               where DBScript should attach its own arguments.
        @return: initialized OptionParser() instance.
        """
        if parser:
            p = parser
        else:
            p = optparse.OptionParser()
            p.set_usage("%prog [options] INI")

        # generic options
        p.add_option("-q", "--quiet", action="store_true",
                     help = "log only errors and warnings")
        p.add_option("-v", "--verbose", action="count",
                     help = "log verbosely")
        p.add_option("-d", "--daemon", action="store_true",
                     help = "go background")
        p.add_option("-V", "--version", action="store_true",
                     help = "print version info and exit")
        p.add_option("", "--ini", action="store_true",
                    help = "display sample ini file")
        p.add_option("", "--set", action="append",
                    help = "override config setting (--set 'PARAM=VAL')")

        # control options
        g = optparse.OptionGroup(p, 'control running process')
        g.add_option("-r", "--reload",
                     action="store_const", const="reload", dest="cmd",
                     help = "reload config (send SIGHUP)")
        g.add_option("-s", "--stop",
                     action="store_const", const="stop", dest="cmd",
                     help = "stop program safely (send SIGINT)")
        g.add_option("-k", "--kill",
                     action="store_const", const="kill", dest="cmd",
                     help = "kill program immediately (send SIGTERM)")
        p.add_option_group(g)

        return p
def init_optparse ( self , parser = None ) : if parser : p = parser else : p = optparse . OptionParser ( ) p . set_usage ( "%prog [options] INI" ) # generic options p . add_option ( "-q" , "--quiet" , action = "store_true" , help = "log only errors and warnings" ) p . add_option ( "-v" , "--verbose" , action = "count" , help = "log verbosely" ) p . add_option ( "-d" , "--daemon" , action = "store_true" , help = "go background" ) p . add_option ( "-V" , "--version" , action = "store_true" , help = "print version info and exit" ) p . add_option ( "" , "--ini" , action = "store_true" , help = "display sample ini file" ) p . add_option ( "" , "--set" , action = "append" , help = "override config setting (--set 'PARAM=VAL')" ) # control options g = optparse . OptionGroup ( p , 'control running process' ) g . add_option ( "-r" , "--reload" , action = "store_const" , const = "reload" , dest = "cmd" , help = "reload config (send SIGHUP)" ) g . add_option ( "-s" , "--stop" , action = "store_const" , const = "stop" , dest = "cmd" , help = "stop program safely (send SIGINT)" ) g . add_option ( "-k" , "--kill" , action = "store_const" , const = "kill" , dest = "cmd" , help = "kill program immediately (send SIGTERM)" ) p . add_option_group ( g ) return p