예제 #1
0
파일: walker.py 프로젝트: parallel-p/pesto
    def _get_submit_from_xml(self, xml_file):
        if self.database == None:
            return None
        try:
            result = ejudge_xml_parse(xml_file)
        except OSError:
            return None

        if result is None:
            return None

        submit_id = result.submit_id
        submit_outcome = result.submit_outcome
        run_outcomes = result.run_outcomes
        scoring = result.scoring

        submit_info = self.database.get_submit_info(self.contest_id, submit_id)

        if submit_info is None:
            return None

        problem_id = submit_info.problem_id
        user_id = submit_info.user_id
        lang_id = submit_info.lang_id
        time_stamp = submit_info.timestamp

        if None in (problem_id, user_id):
            return None

        runs = [Run((self.contest_id, problem_id), submit_id, i + 1, run_outcomes[i][0], run_outcomes[i][1],
                    run_outcomes[i][2]) for i in range(len(run_outcomes))]
        submit = Submit(submit_id, (self.contest_id, problem_id), user_id, lang_id, runs, submit_outcome, scoring,
                        time_stamp)
        return submit
예제 #2
0
 def test_binary(self):
     file = open('testdata/xml/normal.xml', 'rb')  # imagine it is gzipped
     res = ejudge_xml_parse(file)
     file.close()
     self.assertNotEqual(res, None)
     self.assertEqual(res.submit_id, '15')
     self.assertEqual(res.submit_outcome, 'OK')
     self.assertEqual(res.scoring, "kirov")
     self.assertEqual(res.run_outcomes,
                      [('348', '310', 'OK'), ('199', '200', 'OK'), ('327', '240', 'OK'), ('304', '280', 'OK')])
예제 #3
0
 def test_normal(self):
     file = open('testdata/xml/normal.xml', encoding='utf-8')
     res = ejudge_xml_parse(file)
     file.close()
     self.assertNotEqual(res, None)
     self.assertEqual(res.submit_id, '15')
     self.assertEqual(res.submit_outcome, 'OK')
     self.assertEqual(res.scoring, "kirov")
     self.assertEqual(res.run_outcomes,
                      [('348', '310', 'OK'), ('199', '200', 'OK'), ('327', '240', 'OK'), ('304', '280', 'OK')])
예제 #4
0
 def test_wrong_xml(self):
     file = open('testdata/xml/wrong.xml', encoding='utf-8')
     res = ejudge_xml_parse(file)
     file.close()
     self.assertEqual(res, None)
예제 #5
0
 def test_non_unicode(self):
     file = open('testdata/xml/non_unicode.xml', encoding='utf-8')
     res = ejudge_xml_parse(file)
     file.close()
     self.assertEqual(res, None)