Beispiel #1
0
    def test_run(self):
        cmd = command_test.CommandTest()

        parser = argparse.ArgumentParser()
        bg_utils.add_argparse_arguments(parser)
        cmd.add_arguments(parser)
        opts = parser.parse_args([])
        cmd.run(self.accessor, opts)
Beispiel #2
0
    def test_run_with_args(self):
        cmd = command_test.CommandTest()

        parser = argparse.ArgumentParser()
        bg_utils.add_argparse_arguments(parser)
        cmd.add_arguments(parser)
        opts = parser.parse_args(["--cassandra_contact_points=127.0.0.1,192.168.0.1",
                                  "--cassandra_contact_points_metadata=127.0.0.1,192.168.1.1"])
        settings = bg_utils.settings_from_args(opts)
        self.assertIsInstance(settings['cassandra_contact_points'], list)
        self.assertIsInstance(
            settings['cassandra_contact_points_metadata'], list)

        cmd.run(self.accessor, opts)
Beispiel #3
0
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,
                                          add_help=False)  # accept -h for du
        # but we still want --help
        subparser.add_argument('--help',