Example #1
0
def test_download_rdmanifest():
    test_dir = get_test_dir()
    with open(os.path.join(test_dir, 'rep112-example.rdmanifest')) as f:
        expected = yaml.load(f)

    from rosdep2.platforms.source import download_rdmanifest, DownloadFailed
    url = 'file://%s' % os.path.join(test_dir, 'rep112-example.rdmanifest')
    contents, download_url = download_rdmanifest(url, REP112_MD5SUM)
    assert contents == expected
    assert download_url == url

    # test alt_url
    contents, download_url = download_rdmanifest('http://badhostname.willowgarage.com/', REP112_MD5SUM, alt_url=url)
    assert contents == expected
    assert download_url == url

    # test md5sum validate
    try:
        contents, error = download_rdmanifest(url, 'badmd5')
        assert False, "should have errored"
    except DownloadFailed:
        pass

    # test download verify
    try:
        contents, error = download_rdmanifest('http://badhostname.willowgarage.com', 'fakemd5')
        assert False, "should have errored"
    except DownloadFailed:
        pass
Example #2
0
def test_download_rdmanifest():
    test_dir = get_test_dir()
    with open(os.path.join(test_dir, 'rep112-example.rdmanifest')) as f:
        expected = yaml.load(f)

    from rosdep2.platforms.source import download_rdmanifest, DownloadFailed
    url = 'file://%s' % os.path.join(test_dir, 'rep112-example.rdmanifest')
    contents, download_url = download_rdmanifest(url, REP112_MD5SUM)
    assert contents == expected
    assert download_url == url

    # test alt_url
    contents, download_url = download_rdmanifest(
        'http://badhostname.willowgarage.com/', REP112_MD5SUM, alt_url=url)
    assert contents == expected
    assert download_url == url

    # test md5sum validate
    try:
        contents, error = download_rdmanifest(url, 'badmd5')
        assert False, "should have errored"
    except DownloadFailed:
        pass

    # test download verify
    try:
        contents, error = download_rdmanifest(
            'http://badhostname.willowgarage.com', 'fakemd5')
        assert False, "should have errored"
    except DownloadFailed:
        pass
def _install_rdmanifest(uri, prefix):
    if os.path.isfile(uri):
        with open(uri, 'r') as f:
            contents = f.read()
            manifest = load_rdmanifest(contents)
            source_install = SourceInstall.from_manifest(manifest, uri)
            _install_source(source_install)
    else:
        logger.info('Downloading rdmanifest')
        manifest, url = download_rdmanifest(uri, None)
        source_install = SourceInstall.from_manifest(manifest, url)
        _install_source(source_install, prefix)