Пример #1
0
def validate_build(request, username, project_name, build_id):
    project, message = validate_project(request=request,
                                        username=username,
                                        project_name=project_name)
    if project is None:
        return None, message
    try:
        job = BuildJob.objects.get(project=project, id=build_id)
    except (BuildJob.DoesNotExist, ValidationError):
        return None, 'Build was not found'
    if job.is_done:
        return None, 'Job is not running, current status: {}'.format(
            job.last_status)
    return job, None
Пример #2
0
def validate_experiment(request, username, project_name, experiment_id):
    project, message = validate_project(request=request,
                                        username=username,
                                        project_name=project_name)
    if project is None:
        return None, message
    try:
        experiment = Experiment.objects.get(project=project, id=experiment_id)
    except (Experiment.DoesNotExist, ValidationError):
        return None, 'Experiment was not found'
    if experiment.is_done:
        return None, 'Experiment is not running, current status: {}'.format(
            experiment.last_status)
    return experiment, None