def test_get_path_specs_from_uri_from_url(self):
     # wet
     url = "http://ros.org/rosinstalls/fuerte-ros-full.rosinstall"
     path_specs = get_path_specs_from_uri(url)
     self.assertTrue(ros_found_in_path_spec(path_specs), "No ros element in fuerte %s, URL %s" % (path_specs, url))
     # dry
     url = "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=fuerte&variant=desktop-full&overlay=no"
     path_specs = get_path_specs_from_uri(url)
     self.assertTrue(ros_found_in_path_spec(path_specs), "No ros element in fuerte %s, URL %s" % (path_specs, url))
 def test_get_path_specs_from_uri_from_url_pre_electric(self):
     # boxturtle
     url = "http://www.ros.org/rosinstalls/boxturtle_base.rosinstall"
     path_specs = get_path_specs_from_uri(url)
     self.assertTrue(self._ros_found_path_spec(path_specs), "No ros element in boxturtle")
     # diamondback
     uri = "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=diamondback&variant=desktop-full&overlay=no"
     path_specs = get_path_specs_from_uri(uri)
     self.assertTrue(path_specs is not None)
     self.assertTrue(len(path_specs) > 0, "No elements in %s"%uri)
     self.assertTrue(self._ros_found_path_spec(path_specs), "No ros element in %s"%uri)
示例#3
0
 def test_get_yaml_from_uri_from_missing_file(self):
     file = "/asdfasdfasdfasfasdf_does_not_exist"
     try:
         get_yaml_from_uri(file)
         self.fail("Expected exception")
     except MultiProjectException:
         pass
     try:
         get_path_specs_from_uri(file)
         self.fail("Expected exception")
     except MultiProjectException:
         pass
示例#4
0
    def test_get_yaml_from_uri_from_file(self):
        file = os.path.join("test", "example.yaml")
        y = get_yaml_from_uri(file)

        self.assertTrue("text" in y)
        self.assertTrue(y["text"] == "foobar")

        self.assertTrue("number" in y)
        self.assertTrue(y["number"] == 2)
        # invalid
        try:
            yaml = get_yaml_from_uri(os.path.join("test", "example-broken.yaml"))
        except MultiProjectException:
            pass
        try:
            get_path_specs_from_uri(file)
            self.fail("Expected exception")
        except MultiProjectException:
            pass
示例#5
0
def get_config(basepath,
               additional_uris=None,
               config_filename=None,
               merge_strategy='KillAppend'):
    """
    Create a Config element necessary for all other commands.  The
    command will look at the uris in sequence, each can be a web
    resource, a filename or a folder. In case it is a folder, when a
    config_filename is provided, the folder will be searched for a
    file of that name, and that one will be used.  Else the folder
    will be considered a target location for the config.  All files
    will be parsed for config elements, thus conceptually the input to
    Config is an expanded list of config elements. Config takes this
    list and consolidates duplicate paths by keeping the last one in
    the list.

    :param basepath: where relative paths shall be resolved against
    :param additional_uris: the location of config specifications or folders
    :param config_filename: name of files which may be looked at for config information
    :param merge_strategy: One of 'KillAppend, 'MergeKeep', 'MergeReplace'
    :returns: a Config object
    :raises MultiProjectException: on plenty of errors
    """
    if basepath is None:
        raise MultiProjectException("Need to provide a basepath for Config.")

    #print("source...........................", path_specs)

    ## Generate the config class with the uri and path
    if (config_filename is not None
        and basepath is not None
        and os.path.isfile(os.path.join(basepath, config_filename))):

        base_path_specs = get_path_specs_from_uri(os.path.join(basepath,
                                                               config_filename),
                                                  as_is=True)
    else:
        base_path_specs = []

    config = Config(base_path_specs, basepath,
                    config_filename=config_filename,
                    merge_strategy=merge_strategy)

    add_uris(config, additional_uris, merge_strategy)

    return config
    def test_get_path_specs_from_uri_from_url(self):
        url = "http://www.ros.org/rosinstalls/boxturtle_base.rosinstall"
        path_specs = get_path_specs_from_uri(url)

        self.assertTrue(ros_found_in_path_spec(path_specs), "No ros element in boxturtle")
 def test_get_path_specs_from_uri_from_url(self):
     url = "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=electric&variant=ros-base&overlay=no"
     path_specs = get_path_specs_from_uri(url)
     self.assertTrue(ros_found_in_path_spec(path_specs), "No ros element in electric")
 def test_get_path_specs_from_uri_from_url_electric(self):
     uri = "http://packages.ros.org/cgi-bin/gen_rosinstall.py?rosdistro=electric&variant=desktop-full&overlay=no"
     path_specs = get_path_specs_from_uri(uri)
     self.assertTrue(path_specs is not None)
     self.assertTrue(len(path_specs) > 0, "No elements in %s"%uri)
     self.assertTrue(self._ros_found_path_spec(path_specs), "No ros element in %s"%uri)
 def test_get_path_specs_from_uri_from_url(self):
     url = "http://packages.ros.org/web/rosinstall/generate/raw/groovy/ros-base"
     path_specs = get_path_specs_from_uri(url)
     self.assertTrue(ros_found_in_path_spec(path_specs), "No ros element in groovy")