def etl_main(): settings = Settings( usage="[OPTIONS...] PIPELINE [ - | FILE...]", description="Process the specified ETL pipeline", section="etl") try: settings.addOption("H", "host", override="host", help="connect to syslog server HOST", metavar="HOST" ) settings.addOption("f", "filters", override="filters", help="use filter pipeline SPEC", metavar="SPEC" ) settings.addOption("s", "sink", override="sink", help="publish events to the specified STORE", metavar="STORE" ) settings.addLongOption("log-config", override="log config file", help="use logging configuration file FILE", metavar="FILE" ) settings.addSwitch("d", "debug", override="debug", help="Print debugging information" ) # load configuration ns = settings.parse() # create the ETL and run it etl = ETL() etl.configure(ns) return etl.run() except ConfigureError, e: print >> sys.stderr, "%s: %s" % (settings.appname, e)
def search_main(): settings = Settings( usage="[OPTIONS...] QUERY", description="Search a terane cluster", section="search") try: settings.addOption("H", "host", override="host", help="Connect to terane server HOST", metavar="HOST" ) settings.addOption("u", "username", override="username", help="Authenticate with username USER", metavar="USER" ) settings.addOption("p", "password", override="password", help="Authenticate with password PASS", metavar="PASS" ) settings.addSwitch("P", "prompt-password", override="prompt password", help="Prompt for a password" ) settings.addOption("s", "store", override="store", help="Search the specified STORE", metavar="STORE" ) settings.addSwitch("v", "verbose", override="long format", help="Display more information about each event" ) settings.addSwitch("r", "reverse", override="display reverse", help="Display events in reverse order (newest first)" ) settings.addOption("l", "limit", override="limit", help="Display the first LIMIT results", metavar="LIMIT" ) settings.addOption("f", "fields", override="display fields", help="Display only the specified FIELDS (comma-separated)", metavar="FIELDS" ) settings.addOption("t", "timezone", override="timezone", help="Convert timestamps to specified timezone", metavar="TZ" ) settings.addLongOption("log-config", override="log config file", help="use logging configuration file FILE", metavar="FILE" ) settings.addSwitch("d", "debug", override="debug", help="Print debugging information" ) # load configuration ns = settings.parse() # create the Searcher and run it searcher = Searcher() searcher.configure(ns) return searcher.run() except ConfigureError, e: print >> sys.stderr, "%s: %s" % (settings.appname, e)
def run_main(): settings = Settings( usage="[OPTIONS...] PIPELINE", description="Run the specified pipeline", section="run") try: settings.addLongOption("log-config", override="log config file", help="use logging configuration file FILE", metavar="FILE" ) settings.addSwitch("d", "debug", override="debug", help="Print debugging information" ) # load configuration ns = settings.parse() # create the Runner and run it runner = Runner() runner.configure(ns) return runner.run() except ConfigureError, e: print >> sys.stderr, "%s: %s" % (settings.appname, e)
class ActionMap(ActionBase): def __init__(self, usage, description, section=None, options=list(), actions=list()): ActionBase.__init__(self) self.settings = Settings(usage=usage, description=description, section=section) self.options = options self.actions = actions self.callback = None self._init(self.settings, self.options, self.actions) def parse(self, *args, **kwargs): ns = self.settings.parse(*args, **kwargs) action = self name = ns.popStack() while name is not None: action = action.children[name] name = ns.popStack() callback = action.callback if callback is None: raise ConfigureError("no action specified. see --help for usage.") return callback(ns)