Esempio n. 1
0
def create_error_report(env, exc_info, **kwargs):
    """Builds a :class:`oioioi.contests.models.SubmissionReport` for
       an evaulation which have failed.

       USES
           * `env['submission_id']`
    """

    logger.error("System Error evaluating submission #%s:\n%s",
            env.get('submission_id', '???'),
            pprint.pformat(env, indent=4), exc_info=exc_info)

    if 'submission_id' not in env:
        return env

    try:
        submission = Submission.objects.get(id=env['submission_id'])
    except Submission.DoesNotExist:
        return env

    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = 'FAILURE'
    submission_report.save()

    failure_report = FailureReport(submission_report=submission_report)
    failure_report.json_environ = json.dumps(env)
    failure_report.message = traceback.format_exc(exc_info)
    failure_report.save()

    return env
Esempio n. 2
0
def create_error_report(env, exc_info, **kwargs):
    """Builds a :class:`oioioi.contests.models.SubmissionReport` for
       an evaulation which have failed.

       USES
           * `env['submission_id']`
    """

    logger.error("System Error evaluating submission #%s:\n%s",
                 env.get('submission_id', '???'),
                 pprint.pformat(env, indent=4),
                 exc_info=exc_info)

    if 'submission_id' not in env:
        return env

    try:
        submission = Submission.objects.get(id=env['submission_id'])
    except Submission.DoesNotExist:
        return env

    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = 'FAILURE'
    submission_report.save()

    failure_report = FailureReport(submission_report=submission_report)
    failure_report.json_environ = json.dumps(env)
    failure_report.message = traceback.format_exc(exc_info)
    failure_report.save()

    return env
Esempio n. 3
0
def create_error_report(env, submission, exc_info, **kwargs):
    """Builds a :class:`oioioi.contests.models.SubmissionReport` for
    an evaulation which have failed.

    USES
        * `env['submission_id']`
    """

    logger.error(
        "System Error evaluating submission #%s:\n%s",
        env.get('submission_id', '???'),
        pprint.pformat(env, indent=4),
        exc_info=exc_info,
    )

    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = 'FAILURE'
    submission_report.save()

    failure_report = FailureReport(submission_report=submission_report)
    failure_report.json_environ = json.dumps(env)
    failure_report.message = u''.join(traceback.format_exception(*exc_info))
    failure_report.save()

    return env
Esempio n. 4
0
def _make_base_report(env, kind):
    """Helper function making: SubmissionReport, ScoreReport,
       CompilationReport.

       Used ``environ`` keys:
           * ``status``
           * ``score``
           * ``compilation_result``
           * ``compilation_message``
           * ``submission_id``
           * ``max_score``

       Alters ``environ`` by adding:
           * ``report_id``: id of the produced
             :class:`~oioioi.contests.models.SubmissionReport`

       Returns: tuple (submission, submission_report)
    """
    submission = Submission.objects.get(id=env['submission_id'])
    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = kind
    submission_report.save()

    env['report_id'] = submission_report.id

    status_report = ScoreReport(submission_report=submission_report)
    status_report.status = env['status']
    status_report.score = env['score']
    status_report.max_score = env['max_score']
    status_report.save()

    compilation_report = CompilationReport(submission_report=submission_report)
    compilation_report.status = env['compilation_result']
    compilation_message = env['compilation_message']

    if not isinstance(compilation_message, unicode):
        compilation_message = compilation_message.decode('utf8')
    compilation_report.compiler_output = compilation_message
    compilation_report.save()

    return submission, submission_report
Esempio n. 5
0
def _make_base_report(env, kind):
    """Helper function making: SubmissionReport, ScoreReport,
       CompilationReport.

       Used ``environ`` keys:
           * ``status``
           * ``score``
           * ``compilation_result``
           * ``compilation_message``
           * ``submission_id``
           * ``max_score``

       Alters ``environ`` by adding:
           * ``report_id``: id of the produced
             :class:`~oioioi.contests.models.SubmissionReport`

       Returns: tuple (submission, submission_report)
    """
    submission = Submission.objects.get(id=env['submission_id'])
    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = kind
    submission_report.save()

    env['report_id'] = submission_report.id

    status_report = ScoreReport(submission_report=submission_report)
    status_report.status = env['status']
    status_report.score = env['score']
    status_report.max_score = env['max_score']
    status_report.save()

    compilation_report = CompilationReport(submission_report=submission_report)
    compilation_report.status = env['compilation_result']
    compilation_message = env['compilation_message']

    if not isinstance(compilation_message, unicode):
        compilation_message = compilation_message.decode('utf8')
    compilation_report.compiler_output = compilation_message
    compilation_report.save()

    return submission, submission_report
Esempio n. 6
0
def make_report(env, kind="NORMAL", **kwargs):
    """Builds entities for tests results in a database.

       Used ``environ`` keys:
           * ``tests``
           * ``test_results``
           * ``group_results``
           * ``status``
           * ``score``

       Produced ``environ`` keys:
           * ``report_id``: id of the produced
             :class:`~oioioi.contests.models.SubmissionReport`
    """

    submission = Submission.objects.get(id=env["submission_id"])
    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = kind
    submission_report.save()

    status_report = ScoreReport(submission_report=submission_report)
    status_report.status = env["status"]
    status_report.score = env["score"]
    status_report.save()

    compilation_report = CompilationReport(submission_report=submission_report)
    compilation_report.status = env["compilation_result"]
    compilation_message = env["compilation_message"]
    if not isinstance(compilation_message, unicode):
        compilation_message = compilation_message.decode("utf8")
    compilation_report.compiler_output = compilation_message
    compilation_report.save()

    if env["compilation_result"] != "OK":
        return env

    tests = env["tests"]
    test_results = env.get("test_results", {})
    for test_name, result in test_results.iteritems():
        test = tests[test_name]
        if "report_id" in result:
            continue
        test_report = TestReport(submission_report=submission_report)
        test_report.test_id = test.get("id")
        test_report.test_name = test_name
        test_report.test_group = test["group"]
        test_report.test_time_limit = test.get("exec_time_limit")
        test_report.test_max_score = test["max_score"]
        test_report.score = result["score"]
        test_report.status = result["status"]
        test_report.time_used = result["time_used"]
        comment = result.get("result_string", "")
        if comment == "ok":  # Annoying
            comment = ""
        test_report.comment = comment
        test_report.save()
        result["report_id"] = test_report.id

    group_results = env.get("group_results", {})
    for group_name, group_result in group_results.iteritems():
        if "report_id" in group_result:
            continue
        group_report = GroupReport(submission_report=submission_report)
        group_report.group = group_name
        group_report.score = group_result["score"]
        group_report.status = group_result["status"]
        group_report.save()
        group_result["result_id"] = group_report.id

    return env
Esempio n. 7
0
def make_report(env, kind='NORMAL', **kwargs):
    """Builds entities for tests results in a database.

       Used ``environ`` keys:
           * ``tests``
           * ``test_results``
           * ``group_results``
           * ``status``
           * ``score``

       Produced ``environ`` keys:
           * ``report_id``: id of the produced
             :class:`~oioioi.contests.models.SubmissionReport`
    """

    submission = Submission.objects.get(id=env['submission_id'])
    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = kind
    submission_report.save()

    status_report = ScoreReport(submission_report=submission_report)
    status_report.status = env['status']
    status_report.score = env['score']
    status_report.save()

    compilation_report = CompilationReport(submission_report=submission_report)
    compilation_report.status = env['compilation_result']
    compilation_message = env['compilation_message']
    if not isinstance(compilation_message, unicode):
        compilation_message = compilation_message.decode('utf8')
    compilation_report.compiler_output = compilation_message
    compilation_report.save()

    if env['compilation_result'] != 'OK':
        return env

    tests = env['tests']
    test_results = env.get('test_results', {})
    for test_name, result in test_results.iteritems():
        test = tests[test_name]
        if 'report_id' in result:
            continue
        test_report = TestReport(submission_report=submission_report)
        test_report.test_id = test.get('id')
        test_report.test_name = test_name
        test_report.test_group = test['group']
        test_report.test_time_limit = test.get('exec_time_limit')
        test_report.test_max_score = test['max_score']
        test_report.score = result['score']
        test_report.status = result['status']
        test_report.time_used = result['time_used']
        comment = result.get('result_string', '')
        if comment == 'ok':  # Annoying
            comment = ''
        test_report.comment = comment
        test_report.save()
        result['report_id'] = test_report.id

    group_results = env.get('group_results', {})
    for group_name, group_result in group_results.iteritems():
        if 'report_id' in group_result:
            continue
        group_report = GroupReport(submission_report=submission_report)
        group_report.group = group_name
        group_report.score = group_result['score']
        group_report.status = group_result['status']
        group_report.save()
        group_result['result_id'] = group_report.id

    return env
Esempio n. 8
0
def make_report(env, kind='NORMAL', **kwargs):
    """Builds entities for tests results in a database.

       Used ``environ`` keys:
           * ``tests``
           * ``test_results``
           * ``group_results``
           * ``status``
           * ``score``

       Produced ``environ`` keys:
           * ``report_id``: id of the produced
             :class:`~oioioi.contests.models.SubmissionReport`
    """

    submission = Submission.objects.get(id=env['submission_id'])
    submission_report = SubmissionReport(submission=submission)
    submission_report.kind = kind
    submission_report.save()

    status_report = ScoreReport(submission_report=submission_report)
    status_report.status = env['status']
    status_report.score = env['score']
    status_report.save()

    compilation_report = CompilationReport(submission_report=submission_report)
    compilation_report.status = env['compilation_result']
    compilation_message = env['compilation_message']
    if not isinstance(compilation_message, unicode):
        compilation_message = compilation_message.decode('utf8')
    compilation_report.compiler_output = compilation_message
    compilation_report.save()

    if env['compilation_result'] != 'OK':
        return env

    tests = env['tests']
    test_results = env.get('test_results', {})
    for test_name, result in test_results.iteritems():
        test = tests[test_name]
        if 'report_id' in result:
            continue
        test_report = TestReport(submission_report=submission_report)
        test_report.test_id = test.get('id')
        test_report.test_name = test_name
        test_report.test_group = test['group']
        test_report.test_time_limit = test.get('exec_time_limit')
        test_report.test_max_score = test['max_score']
        test_report.score = result['score']
        test_report.status = result['status']
        test_report.time_used = result['time_used']
        comment = result.get('result_string', '')
        if comment == 'ok':  # Annoying
            comment = ''
        test_report.comment = comment
        test_report.save()
        result['report_id'] = test_report.id

    group_results = env.get('group_results', {})
    for group_name, group_result in group_results.iteritems():
        if 'report_id' in group_result:
            continue
        group_report = GroupReport(submission_report=submission_report)
        group_report.group = group_name
        group_report.score = group_result['score']
        group_report.status = group_result['status']
        group_report.save()
        group_result['result_id'] = group_report.id

    return env