Esempio n. 1
0
 def __init__(self, opts):
     settings = bg_settings.settings_from_args(opts)
     bg_utils.set_log_level(settings)
     self._accessor = bg_accessor_factory.accessor_from_settings(settings)
     self._opts = opts
     self.time_start = time.mktime(self._opts.time_start.timetuple())
     self.time_end = time.mktime(self._opts.time_end.timetuple())
Esempio n. 2
0
 def __init__(self, opts):
     settings = bg_settings.settings_from_args(opts)
     bg_utils.set_log_level(settings)
     self._accessor = bg_accessor_factory.accessor_from_settings(settings)
     self._opts = opts
     self.time_start = time.mktime(self._opts.time_start.timetuple())
     self.time_end = time.mktime(self._opts.time_end.timetuple())
Esempio n. 3
0
    def run(self, accessor, opts):
        """Run the command."""
        # Import only here so that if the optional `gourde` dep
        # is missing we can still import the file.
        from biggraphite.cli.web import app

        # TODO: accessor.connect() could be called asynchronously later.
        accessor.connect()

        webapp = app.WebApp()
        utils.start_admin(settings.settings_from_args(opts))
        webapp.initialize_app(accessor, opts)
        if not opts.dry_run:
            webapp.run()
Esempio n. 4
0
def main(args=None, accessor=None):
    """Entry point for the module."""
    if not args:
        args = sys.argv[1:]

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

    settings = bg_settings.settings_from_args(opts)
    bg_utils.set_log_level(settings)
    accessor = accessor or bg_accessor_factory.accessor_from_settings(settings)
    opts.func(accessor, opts)
    accessor.flush()
    accessor.shutdown()
    def test_run_with_args(self):
        cmd = command_test.CommandTest()

        parser = argparse.ArgumentParser()
        bg_settings.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_settings.settings_from_args(opts)
        self.assertIsInstance(settings["cassandra_contact_points"], list)
        self.assertIsInstance(settings["cassandra_contact_points_metadata"], list)

        cmd.run(self.accessor, opts)