Ejemplo n.º 1
0
 def test_update_configuration(self):
     default_config = configuration.DEFAULTS
     update_dict = {
         "pypi_index_url": "http://pypi-ninja.ninjacorp.com/simple"}
     updated_config = configuration.update_configuration(
         default_config, update_dict)
     assert default_config.pypi_index_url == None
     assert updated_config.pypi_index_url == \
                    "http://pypi-ninja.ninjacorp.com/simple"
Ejemplo n.º 2
0
 def test_update_configuration(self):
     default_config = configuration.DEFAULTS
     update_dict = {
         "pypi_index_url": "http://pypi-ninja.ninjacorp.com/simple"
     }
     updated_config = configuration.update_configuration(
         default_config, update_dict)
     assert default_config.pypi_index_url == None
     assert updated_config.pypi_index_url == \
                    "http://pypi-ninja.ninjacorp.com/simple"
Ejemplo n.º 3
0
def _ensure_storm_path_in_configs(configs):
    """Ensure that the storm executable path is in the configuration.
    If not present, search for it and update the config.

    :raise: ConfigurationError if unable to locate storm path
    """

    if configs.storm_cmd_path is not None:
        return configs

    storm_cmd_path = search_storm_cmd_path()
    if storm_cmd_path is None:
        raise ConfigurationError(
            "Unable to locate Storm executable. Please either install "
            "Storm or specify its path in your configuration file")

    return update_configuration(configs, {"storm_cmd_path": storm_cmd_path})
Ejemplo n.º 4
0
def _ensure_storm_path_in_configs(configs):
    """Ensure that the storm executable path is in the configuration.
    If not present, search for it and update the config.

    :raise: ConfigurationError if unable to locate storm path
    """

    if configs.storm_cmd_path is not None:
        return configs

    storm_cmd_path = search_storm_cmd_path()
    if storm_cmd_path is None:
        raise ConfigurationError(
            "Unable to locate Storm executable. Please either install "
            "Storm or specify its path in your configuration file"
        )

    return update_configuration(configs, {"storm_cmd_path": storm_cmd_path})
Ejemplo n.º 5
0
    def run_subcommand(self, arguments):
        """Load the configuration, update it with the arguments and options
        specified on the command-line and then call the run method implemented
        by each sub-command.
        """
        # Expand path of the command-line specified config file, if any
        if arguments.config_file is not None:
            arguments.config_file = expand_path(arguments.config_file)

        # Load configurations into a Configuration named tuple
        try:
            configs = load_configuration(arguments.config_file)
        except PyleusError as e:
            self.error(e)

        configs = _ensure_storm_path_in_configs(configs)

        # Update configuration with command line values
        configs = update_configuration(configs, vars(arguments))

        try:
            self.run(configs)
        except PyleusError as e:
            self.error(e)
Ejemplo n.º 6
0
    def run_subcommand(self, arguments):
        """Load the configuration, update it with the arguments and options
        specified on the command-line and then call the run method implemented
        by each sub-command.
        """
        # Expand path of the command-line specified config file, if any
        if arguments.config_file is not None:
            arguments.config_file = expand_path(arguments.config_file)

        # Load configurations into a Configuration named tuple
        try:
            configs = load_configuration(arguments.config_file)
        except PyleusError as e:
            self.error(e)

        configs = _ensure_storm_path_in_configs(configs)

        # Update configuration with command line values
        configs = update_configuration(configs, vars(arguments))

        try:
            self.run(configs)
        except PyleusError as e:
            self.error(e)