Ejemplo n.º 1
0
def versions(server, channel, size):
    """ List versions.

    A list of the version names is returned if the query was successful, else
    the error dictionary from SpaceGDN is returned.

    """
    server = spacegdn.get_id(jar=server)
    if server == -1:
        raise ValueError('Could not find server')
    if channel is not None:
        channel = spacegdn.get_id(jar=server, channel=channel)
        if channel == -1:
            raise ValueError('Could not find channel')
    result = spacegdn.versions(jar=server, channel=channel)

    if type(result) is not list:
        return result

    # Sort and limit the results
    result = list(reversed(sorted([version['version'] for version in result])))
    if size >= 0:
        result = result[:min(size, len(result))]
    else:
        result = result[max(size, -len(result)):]

    return result
Ejemplo n.º 2
0
def versions(server, channel, size):
    """ List versions.

    A list of the version names is returned if the query was successful, else
    the error dictionary from SpaceGDN is returned.

    """
    server = spacegdn.get_id(jar=server)
    if server == -1:
        raise ValueError('Could not find server')
    if channel is not None:
        channel = spacegdn.get_id(jar=server, channel=channel)
        if channel == -1:
            raise ValueError('Could not find channel')
    result = spacegdn.versions(jar=server, channel=channel)

    if type(result) is not list:
        return result

    # Sort and limit the results
    result = list(reversed(sorted([version['version'] for version
                                   in result])))
    if size >= 0:
        result = result[:min(size, len(result))]
    else:
        result = result[max(size, -len(result)):]

    return result
Ejemplo n.º 3
0
def find_latest_build(build_list):
    """ Find the latest build in a list of builds. """
    build_list.sort(key=lambda build: build['build'], reverse=True)
    build = build_list[0]

    channel = spacegdn.channels(channel=build['channel_id'])[0]['name']
    version = spacegdn.versions(version=build['version_id'])[0]['version']

    return channel, version, build
Ejemplo n.º 4
0
def find_latest_build(build_list):
    """ Find the latest build in a list of builds. """
    build_list.sort(key=lambda build: build['build'], reverse=True)
    build = build_list[0]

    channel = spacegdn.channels(channel=build['channel_id'])[0]['name']
    version = spacegdn.versions(version=build['version_id'])[0]['version']

    return channel, version, build
Ejemplo n.º 5
0
def get_roots(build):
    """ Get the roots(server, channel, version and build) of this build.

    The returned value is a tuple of the server name, channel name, version
    name and build number.

    """
    server = spacegdn.jars(build['jar_id'])[0]['name']
    channel = spacegdn.channels(build['jar_id'],
                                build['channel_id'])[0]['name']
    version = spacegdn.versions(build['jar_id'], build['channel_id'],
                                build['version_id'])[0]['version']
    build = build['build']

    return server, channel, version, build
Ejemplo n.º 6
0
def get_roots(build):
    """ Get the roots(server, channel, version and build) of this build.

    The returned value is a tuple of the server name, channel name, version
    name and build number.

    """
    server = spacegdn.jars(build['jar_id'])[0]['name']
    channel = spacegdn.channels(build['jar_id'],
                                build['channel_id'])[0]['name']
    version = spacegdn.versions(build['jar_id'], build['channel_id'],
                                build['version_id'])[0]['version']
    build = build['build']

    return server, channel, version, build