Ejemplo n.º 1
0
def compare_nvrs(a_nvr, b_nvr):
    (a_name, a_version) = chacra.name_version(a_nvr)
    (b_name, b_version) = chacra.name_version(b_nvr)
    if sys.version_info[0] < 3:
        compare_names = cmp(a_name, b_name)  # NOQA: F821
    else:
        compare_names = (a_name > b_name) - (a_name < b_name)
    if compare_names != 0:
        return compare_names
    return debian_support.version_compare(a_version, b_version)
Ejemplo n.º 2
0
def ensure_uploaded(nvr, chacra_url, rsession, session, owner, scm_template,
                    dryrun):
    """
    Ensure this build is uploaded into Koji.

    :param nvr: build's name_versionrelease in chacra
    :param chacra_url: base url to chacra instance
    :param rsession: requests.Session object
    :param session: Koji session
    :param owner: Koji user name that will own this build
    :param scm_template: format string for this build's scm_url
    :param dryrun: if True, show what would have happened, but don't do it
    """
    koji_nvr = get_koji_nvr(nvr)
    # Check if this build exists in Koji
    buildinfo = session.getBuild(koji_nvr)
    if buildinfo:
        return buildinfo
    if dryrun:
        log.info('would download chacra build %s' % nvr)
        return
    directory = chacra.download_build(nvr, chacra_url, rsession)
    skip_log = True
    (name, version) = chacra.name_version(nvr)
    scm_url = scm_template.format(name=name)
    buildinfo = upload.import_from_directory(directory, session, owner,
                                             skip_log, scm_url, dryrun)
    return buildinfo
Ejemplo n.º 3
0
def get_source_urls(nvr, base_url, session):
    (pkg, version) = name_version(nvr)
    src_url = posixpath.join(base_url, 'binaries/', pkg, version,
                             'ubuntu', 'all', 'source')
    log.debug('searching %s for files' % src_url)
    src_response = session.get(src_url)
    if src_response.status_code == 404:
        raise NoFilesFoundException('%s has no source files' % nvr)
    src_response.raise_for_status()
    payload = src_response.json()
    urls = set()
    for filename in payload:
        url = posixpath.join(src_url, filename)
        urls.add(url)
    return urls
Ejemplo n.º 4
0
def test_name_version(nvr, expected):
    result = chacra.name_version(nvr)
    assert result == expected
Ejemplo n.º 5
0
def test_bad_name_version(nvr):
    with pytest.raises(ValueError):
        chacra.name_version(nvr)