示例#1
0
def buildlogs(build_uuid):
    found_build = model.build.get_repository_build(build_uuid)
    if not found_build:
        abort(403)

    repo = found_build.repository
    has_permission = ModifyRepositoryPermission(repo.namespace_user.username,
                                                repo.name).can()
    if features.READER_BUILD_LOGS and not has_permission:
        if ReadRepositoryPermission(
                repo.namespace_user.username,
                repo.name).can() or model.repository.repository_is_public(
                    repo.namespace_user.username, repo.name):
            has_permission = True

    if not has_permission:
        abort(403)

    # If the logs have been archived, just return a URL of the completed archive
    if found_build.logs_archived:
        return redirect(
            log_archive.get_file_url(found_build.uuid, get_request_ip()))

    _, logs = build_logs.get_log_entries(found_build.uuid, 0)
    response = jsonify({"logs": [log for log in logs]})

    response.headers[
        "Content-Disposition"] = "attachment;filename=" + found_build.uuid + ".json"
    return response
示例#2
0
文件: build.py 项目: sabre1041/quay-1
def get_logs_or_log_url(build):
    # If the logs have been archived, just return a URL of the completed archive
    if build.logs_archived:
        return {
            "logs_url":
            log_archive.get_file_url(build.uuid,
                                     get_request_ip(),
                                     requires_cors=True)
        }
    start = int(request.args.get("start", 0))

    try:
        count, logs = build_logs.get_log_entries(build.uuid, start)
    except BuildStatusRetrievalError:
        count, logs = (0, [])

    response_obj = {}
    response_obj.update({
        "start": start,
        "total": count,
        "logs": [log for log in logs],
    })

    return response_obj