コード例 #1
0
ファイル: __init__.py プロジェクト: DSDev-NickHogle/terane
def console_main():
    try:
        settings = Settings(usage="[OPTIONS...] [QUERY]")
        settings.addOption("H", "--host", "console", "host",
            help="Connect to terane server HOST", metavar="HOST"
            )
        settings.addOption("u", "username", "console", "username",
            help="Authenticate with username USER", metavar="USER"
            )
        settings.addOption("p", "password", "console", "password",
            help="Authenticate with password PASS", metavar="PASS"
            )
        settings.addSwitch("P", "prompt-password", "console", "prompt password",
            help="Prompt for a password"
            )
        settings.addOption("e","execute", "console", "execute command",
            help="Execute CMD after startup", metavar="CMD"
            )
        settings.addOption('', "log-config", "console", "log config file",
            help="use logging configuration file FILE", metavar="FILE"
            )
        settings.addSwitch("d", "debug", "console", "debug",
            help="Print debugging information"
            )
        settings.load()
        console.configure(settings)
        return console.run()
    except ConfigureError, e:
        print >> sys.stderr, "%s: %s" % (settings.appname, e)
コード例 #2
0
ファイル: __init__.py プロジェクト: msfrank/terane
def server_main():
    try:
        settings = Settings(usage="[OPTIONS...]")
        settings.addSwitch("d", "debug", "server", "debug",
            help="do not fork into the background, log to stderr",
            )
        settings.addOption("f", "log-file", "server", "log file",
            help="log messages to FILE (--debug overrides this)", metavar="FILE"
            )
        settings.addOption('', "log-config", "server", "log config file",
            help="use logging configuration file FILE", metavar="FILE"
            )
        settings.addOption("p", "pid-file", "server", "pid file",
            help="write PID to FILE", metavar="FILE"
            )
        # load settings from command line arguments, config file
        settings.load(needsconfig=True)
        # configure the server
        server = Server()
        server.configure(settings)
        # start the server
        status = server.run()
        return
    except (ConfigureError,ServerError), e:
        print >> sys.stderr, "%s: %s" % (settings.appname, e)
コード例 #3
0
ファイル: __init__.py プロジェクト: msfrank/terane
def grok_main():
    try:
        settings = Settings(usage="[OPTIONS...] COMMAND")
        # declare global options
        settings.addOption("H","host", "grok", "host",
            help="Connect to terane server HOST", metavar="HOST"
            )
        settings.addOption("u", "username", "grok", "username",
            help="Authenticate with username USER", metavar="USER"
            )
        settings.addOption("p", "password", "grok", "password",
            help="Authenticate with password PASS", metavar="PASS"
            )
        settings.addSwitch("P", "prompt-password", "grok", "prompt password",
            help="Prompt for a password"
            )
        settings.addOption('',"log-config", "grok", "log config file",
            help="use logging configuration file FILE", metavar="FILE"
            )
        settings.addSwitch("d","debug", "grok", "debug",
            help="Print debugging information"
            )
        # declare list-indices command
        settings.addSubcommand("list-indices", usage="",
            description="List available indices", handler=commands.ListIndices
            )
        # declare show-index command
        settings.addSubcommand("show-index", usage="[OPTIONS...] INDEX",
            description="Show index statistics", handler=commands.ShowIndex
            )
        # declare show-stats command
        subcommand = settings.addSubcommand("show-stats", usage="[OPTIONS...] STAT",
            description="Display server statistics", handler=commands.ShowStats
            )
        subcommand.addSwitch("r", "recursive", "show-stats", "recursive",
            help="Recursively display all stats"
            )
        # declare flush-stats command
        subcommand = settings.addSubcommand("flush-stats", usage="[OPTIONS...]",
            description="Reset server statistics", handler=commands.FlushStats
            )
        subcommand.addSwitch("a", "all", "flush-stats", "flush all",
            help="Reset persistent statistics as well"
            )
        # load configuration
        settings.load()
        # create the Searcher and run it
        handler = settings.getHandler()
        command = handler()
        command.configure(settings)
        return command.run()
    except ConfigureError, e:
        print >> sys.stderr, "%s: %s" % (settings.appname, e)
コード例 #4
0
def console_main():
    try:
        settings = Settings(usage="[OPTIONS...] [QUERY]")
        settings.addOption("H",
                           "--host",
                           "console",
                           "host",
                           help="Connect to terane server HOST",
                           metavar="HOST")
        settings.addOption("u",
                           "username",
                           "console",
                           "username",
                           help="Authenticate with username USER",
                           metavar="USER")
        settings.addOption("p",
                           "password",
                           "console",
                           "password",
                           help="Authenticate with password PASS",
                           metavar="PASS")
        settings.addSwitch("P",
                           "prompt-password",
                           "console",
                           "prompt password",
                           help="Prompt for a password")
        settings.addOption("e",
                           "execute",
                           "console",
                           "execute command",
                           help="Execute CMD after startup",
                           metavar="CMD")
        settings.addOption('',
                           "log-config",
                           "console",
                           "log config file",
                           help="use logging configuration file FILE",
                           metavar="FILE")
        settings.addSwitch("d",
                           "debug",
                           "console",
                           "debug",
                           help="Print debugging information")
        settings.load()
        console.configure(settings)
        return console.run()
    except ConfigureError, e:
        print >> sys.stderr, "%s: %s" % (settings.appname, e)
コード例 #5
0
ファイル: __init__.py プロジェクト: msfrank/terane
def search_main():
    try:
        settings = Settings(usage="[OPTIONS...] QUERY")
        settings.addOption("H", "host", "search", "host",
            help="Connect to terane server HOST", metavar="HOST"
            )
        settings.addOption("u", "username", "search", "username",
            help="Authenticate with username USER", metavar="USER"
            )
        settings.addOption("p", "password", "search", "password",
            help="Authenticate with password PASS", metavar="PASS"
            )
        settings.addSwitch("P", "prompt-password", "search", "prompt password",
            help="Prompt for a password"
            )
        settings.addOption("i", "use-indices", "search", "use indices",
            help="Search only the specified INDICES (comma-separated)", metavar="INDICES"
            )
        settings.addSwitch("v", "verbose", "search", "long format",
            help="Display more information about each event"
            )
        settings.addSwitch("r", "reverse", "search", "display reverse",
            help="Display events in reverse order (newest first)"
            )
        settings.addOption("l", "limit", "search", "limit",
            help="Display the first LIMIT results", metavar="LIMIT"
            )
        settings.addOption("f", "fields", "search", "display fields",
            help="Display only the specified FIELDS (comma-separated)", metavar="FIELDS"
            )
        settings.addOption("t", "timezone", "search", "timezone",
            help="Convert timestamps to specified timezone", metavar="TZ"
            )
        settings.addOption('', "log-config", "search", "log config file",
            help="use logging configuration file FILE", metavar="FILE"
            )
        settings.addSwitch("d", "debug", "search", "debug",
            help="Print debugging information"
            )
        # load configuration
        settings.load()
        # create the Searcher and run it
        searcher = Searcher()
        searcher.configure(settings)
        return searcher.run()
    except ConfigureError, e:
        print >> sys.stderr, "%s: %s" % (settings.appname, e)