示例#1
0
def main(args=None, accessor=None):
    """Entry point for the module."""
    if not args:
        args = sys.argv[1:]

    opts = _parse_opts(args)
    if not getattr(opts, "func", None):
        opts.func = command_shell.CommandShell().run

    settings = bg_utils.settings_from_args(opts)
    bg_utils.set_log_level(settings)
    accessor = accessor or bg_utils.accessor_from_settings(settings)
    opts.func(accessor, opts)
    accessor.flush()
    accessor.shutdown()
示例#2
0
    command_test,
    command_write,
)

COMMANDS = [
    command_clean.CommandClean(),
    command_copy.CommandCopy(),
    command_daemon.CommandDaemon(),
    command_delete.CommandDelete(),
    command_du.CommandDu(),
    command_graphite_web.CommandGraphiteWeb(),
    command_info.CommandInfo(),
    command_list.CommandList(),
    command_read.CommandRead(),
    command_repair.CommandRepair(),
    command_shell.CommandShell(),
    command_stats.CommandStats(),
    command_syncdb.CommandSyncdb(),
    command_test.CommandTest(),
    command_write.CommandWrite(),
]


def _parse_opts(args):
    """Parse command line arguments."""
    parser = argparse.ArgumentParser(
        description="BigGraphite command line utility.")
    bg_utils.add_argparse_arguments(parser)
    subparsers = parser.add_subparsers(help="commands")
    for command in COMMANDS:
        subparser = subparsers.add_parser(command.NAME,